MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / attachHeader

Function attachHeader

server/common/proxy.go:73–88  ·  view source on GitHub ↗
(w http.ResponseWriter, file model.Obj, link *model.Link)

Source from the content-addressed store, hash-verified

71 return err
72}
73func attachHeader(w http.ResponseWriter, file model.Obj, link *model.Link) {
74 fileName := file.GetName()
75 w.Header().Set("Content-Disposition", utils.GenerateContentDisposition(fileName))
76 w.Header().Set("Content-Type", utils.GetMimeType(fileName))
77 size := link.ContentLength
78 if size <= 0 {
79 size = file.GetSize()
80 }
81 w.Header().Set("Etag", GetEtag(file, size))
82 contentType := link.Header.Get("Content-Type")
83 if len(contentType) > 0 {
84 w.Header().Set("Content-Type", contentType)
85 } else {
86 w.Header().Set("Content-Type", utils.GetMimeType(fileName))
87 }
88}
89func GetEtag(file model.Obj, size int64) string {
90 hash := ""
91 for _, v := range file.GetHash().Export() {

Callers 1

ProxyFunction · 0.85

Calls 8

GetMimeTypeFunction · 0.92
GetEtagFunction · 0.85
HeaderMethod · 0.80
GetNameMethod · 0.65
GetSizeMethod · 0.65
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected