Changeset 41975 in webkit


Ignore:
Timestamp:
Mar 25, 2009 8:09:24 AM (15 years ago)
Author:
kov@webkit.org
Message:

2009-03-25 Gustavo Noronha Silva <Gustavo Noronha Silva>

Reviewed by Holger Freyther.

https://bugs.webkit.org/show_bug.cgi?id=24750
[GTK] requests download instead of displaying page

Fix the Content-Type headers we get from soup, so that we set a
proper media type on the ResourceResponse.

  • platform/network/soup/ResourceHandleSoup.cpp: (WebCore::fillResponseFromMessage):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41974 r41975  
     12009-03-25  Gustavo Noronha Silva  <gns@gnome.org>
     2
     3        Reviewed by Holger Freyther.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=24750
     6        [GTK] requests download instead of displaying page
     7
     8        Fix the Content-Type headers we get from soup, so that we set a
     9        proper media type on the ResourceResponse.
     10
     11        * platform/network/soup/ResourceHandleSoup.cpp:
     12        (WebCore::fillResponseFromMessage):
     13
    1142009-03-25  Gustavo Noronha Silva  <gns@gnome.org>
    215
  • trunk/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r41974 r41975  
    160160        response->setHTTPHeaderField(name, value);
    161161
    162     String contentType = soup_message_headers_get(msg->response_headers, "Content-Type");
     162    GHashTable* contentTypeParameters = 0;
     163    String contentType = soup_message_headers_get_content_type(msg->response_headers, &contentTypeParameters);
     164
     165    // When the server sends multiple Content-Type headers, soup will
     166    // give us their values concatenated with commas as a separator;
     167    // we need to handle this and use only one value. We use the first
     168    // value, and add all the parameters, afterwards, if any.
     169    Vector<String> contentTypes;
     170    contentType.split(',', true, contentTypes);
     171    contentType = contentTypes[0];
     172
     173    if (contentTypeParameters) {
     174        GHashTableIter hashTableIter;
     175        gpointer hashKey;
     176        gpointer hashValue;
     177
     178        g_hash_table_iter_init(&hashTableIter, contentTypeParameters);
     179        while (g_hash_table_iter_next(&hashTableIter, &hashKey, &hashValue)) {
     180            contentType += String("; ");
     181            contentType += String(static_cast<char*>(hashKey));
     182            contentType += String("=");
     183            contentType += String(static_cast<char*>(hashValue));
     184        }
     185        g_hash_table_destroy(contentTypeParameters);
     186    }
     187
     188    response->setMimeType(extractMIMETypeFromMediaType(contentType));
     189
    163190    char* uri = soup_uri_to_string(soup_message_get_uri(msg), false);
    164191    response->setURL(KURL(KURL(), uri));
    165192    g_free(uri);
    166     response->setMimeType(extractMIMETypeFromMediaType(contentType));
    167193    response->setTextEncodingName(extractCharsetFromMediaType(contentType));
    168194    response->setExpectedContentLength(soup_message_headers_get_content_length(msg->response_headers));
Note: See TracChangeset for help on using the changeset viewer.