X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=WebCore%2Fplatform%2Fnetwork%2Fsoup%2FResourceHandleSoup.cpp;h=b723c4be39987f8910cd64f0013a50407be5217f;hp=de5168f4959e9ee8977f340818932a590e146a3e;hb=c231c64db552e931355ac7cf5de69b0725d84a12;hpb=643b8c2e41e37777600eb0d20437a2f2d1c52cb1;ds=sidebyside diff --git a/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/WebCore/platform/network/soup/ResourceHandleSoup.cpp index de5168f..b723c4b 100644 --- a/WebCore/platform/network/soup/ResourceHandleSoup.cpp +++ b/WebCore/platform/network/soup/ResourceHandleSoup.cpp @@ -159,11 +159,37 @@ static void fillResponseFromMessage(SoupMessage* msg, ResourceResponse* response while (soup_message_headers_iter_next(&iter, &name, &value)) response->setHTTPHeaderField(name, value); - String contentType = soup_message_headers_get(msg->response_headers, "Content-Type"); + GHashTable* contentTypeParameters = 0; + String contentType = soup_message_headers_get_content_type(msg->response_headers, &contentTypeParameters); + + // When the server sends multiple Content-Type headers, soup will + // give us their values concatenated with commas as a separator; + // we need to handle this and use only one value. We use the first + // value, and add all the parameters, afterwards, if any. + Vector contentTypes; + contentType.split(',', true, contentTypes); + contentType = contentTypes[0]; + + if (contentTypeParameters) { + GHashTableIter hashTableIter; + gpointer hashKey; + gpointer hashValue; + + g_hash_table_iter_init(&hashTableIter, contentTypeParameters); + while (g_hash_table_iter_next(&hashTableIter, &hashKey, &hashValue)) { + contentType += String("; "); + contentType += String(static_cast(hashKey)); + contentType += String("="); + contentType += String(static_cast(hashValue)); + } + g_hash_table_destroy(contentTypeParameters); + } + + response->setMimeType(extractMIMETypeFromMediaType(contentType)); + char* uri = soup_uri_to_string(soup_message_get_uri(msg), false); response->setURL(KURL(KURL(), uri)); g_free(uri); - response->setMimeType(extractMIMETypeFromMediaType(contentType)); response->setTextEncodingName(extractCharsetFromMediaType(contentType)); response->setExpectedContentLength(soup_message_headers_get_content_length(msg->response_headers)); response->setHTTPStatusCode(msg->status_code);