Bug 168299 - [SOUP] Ensure a response MIME type when Content-Type is missing and sniffing not allowed
Summary: [SOUP] Ensure a response MIME type when Content-Type is missing and sniffing ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: LayoutTestFailure, Soup
Depends on:
Blocks:
 
Reported: 2017-02-14 02:52 PST by Carlos Garcia Campos
Modified: 2017-02-14 03:56 PST (History)
1 user (show)

See Also:


Attachments
Patch (3.26 KB, patch)
2017-02-14 03:06 PST, Carlos Garcia Campos
svillar: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2017-02-14 02:52:31 PST
Sniffing is not allowed but we can try to guess the MIME using the response path, or at least fallback to default MIME type instead of leaving an empty string. This will fix a couple of tests that expect application/octet-stream in this particular case.
Comment 1 Carlos Garcia Campos 2017-02-14 03:06:16 PST
Created attachment 301481 [details]
Patch
Comment 2 Sergio Villar Senin 2017-02-14 03:35:03 PST
Comment on attachment 301481 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301481&action=review

> Source/WebKit2/NetworkProcess/soup/NetworkDataTaskSoup.cpp:334
> +        }

What about just adding

if (m_response.mimeType().isEmpty() && m_soupMessage->status_code != SOUP_STATUS_NOT_MODIFIED)
    m_response.setMimeType(MIMETypeRegistry::getMIMETypeForPath(m_response.url().path()));

to the previous code? I prefer that option because it  clearly shows that the call to updateFromSoupMessage is unconditional.
Comment 3 Carlos Garcia Campos 2017-02-14 03:47:09 PST
Comment on attachment 301481 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301481&action=review

>> Source/WebKit2/NetworkProcess/soup/NetworkDataTaskSoup.cpp:334
>> +        }
> 
> What about just adding
> 
> if (m_response.mimeType().isEmpty() && m_soupMessage->status_code != SOUP_STATUS_NOT_MODIFIED)
>     m_response.setMimeType(MIMETypeRegistry::getMIMETypeForPath(m_response.url().path()));
> 
> to the previous code? I prefer that option because it  clearly shows that the call to updateFromSoupMessage is unconditional.

Yes, I thought about that, and I didn't do it to avoid checking 304 twice, but it's not a big deal anyway. I'll update it before landing, thanks for the review.
Comment 4 Carlos Garcia Campos 2017-02-14 03:56:47 PST
Committed r212286: <http://trac.webkit.org/changeset/212286>