Bug 168299

Summary: [SOUP] Ensure a response MIME type when Content-Type is missing and sniffing not allowed
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply
Priority: P2 Keywords: LayoutTestFailure, Soup
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch svillar: review+

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>