MCPcopy Index your code
hub / github.com/imroc/req / createMultipartHeader

Function createMultipartHeader

middleware.go:29–54  ·  view source on GitHub ↗
(file *FileUpload, contentType string)

Source from the content-addressed store, hash-verified

27)
28
29func createMultipartHeader(file *FileUpload, contentType string) textproto.MIMEHeader {
30 hdr := make(textproto.MIMEHeader)
31
32 contentDispositionValue := "form-data"
33 cd := new(ContentDisposition)
34 if file.ParamName != "" {
35 cd.Add("name", file.ParamName)
36 }
37 if file.FileName != "" {
38 cd.Add("filename", file.FileName)
39 }
40 if file.ExtraContentDisposition != nil {
41 for _, kv := range file.ExtraContentDisposition.kv {
42 cd.Add(kv.Key, kv.Value)
43 }
44 }
45 if c := cd.string(); c != "" {
46 contentDispositionValue += c
47 }
48 hdr.Set("Content-Disposition", contentDispositionValue)
49
50 if !util.IsStringEmpty(contentType) {
51 hdr.Set(header.ContentType, contentType)
52 }
53 return hdr
54}
55
56func closeq(v any) {
57 if c, ok := v.(io.Closer); ok {

Callers 1

writeMultipartFormFileFunction · 0.85

Calls 3

IsStringEmptyFunction · 0.92
AddMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…