Skip to content

Commit d774bdd

Browse files
committed
Prioritize the content-type header for attachments response for mimetype detection
1 parent ff06bf4 commit d774bdd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: attachments.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ func FetchAndStoreAttachment(ctx context.Context, b Backend, channel Channel, at
127127
}
128128
}
129129

130-
// we still don't know our mime type, use our content header instead
131-
if mimeType == "" {
132-
mimeType, _, _ = mime.ParseMediaType(trace.Response.Header.Get("Content-Type"))
130+
// prioritize to use the response content type header if provided
131+
contentTypeHeader := trace.Response.Header.Get("Content-Type")
132+
if contentTypeHeader != "" {
133+
mimeType, _, _ = mime.ParseMediaType(contentTypeHeader)
133134
if extension == "" {
134135
extensions, err := mime.ExtensionsByType(mimeType)
135136
if extensions == nil || err != nil {

0 commit comments

Comments
 (0)