Summary: | [GTK] requests download instead of displaying page | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Gustavo Noronha (kov) <gustavo> | ||||||
Component: | WebKitGTK | Assignee: | Gustavo Noronha (kov) <gustavo> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | Keywords: | Gtk, Soup | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | PC | ||||||||
OS: | All | ||||||||
URL: | http://lhv.delfi.ee/news/index.cfm?id=1146314 | ||||||||
Attachments: |
|
Description
Gustavo Noronha (kov)
2009-03-22 14:12:23 PDT
Created attachment 28840 [details]
proposed fix
Comment on attachment 28840 [details] proposed fix > - String contentType = soup_message_headers_get(msg->response_headers, "Content-Type"); > + GHashTable *contentTypeParameters = 0; style, '*' pleaced wrongly. > + if (!contentType.isEmpty() && contentType.find(",", 0)) { > + Vector<String> contentTypes; > + contentType.split(',', contentTypes); > + contentType = contentTypes[0]; > + } Interesting question. What is faster... searching the string twice or creating the Vector? > + > + 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 += "; "; > + contentType += static_cast<char*>(hashKey); > + contentType += "="; > + contentType += static_cast<char*>(hashValue); > + } You could consider using StringBuilder here. And another thing. With HTTP headers are like ASCII which makes your use of String(char*) okay, but maybe write String() around it as well to highlight that we really want this. Landed as r41975. (In reply to comment #2) > > + if (!contentType.isEmpty() && contentType.find(",", 0)) { > > + Vector<String> contentTypes; > > + contentType.split(',', contentTypes); > > + contentType = contentTypes[0]; > > + } > > Interesting question. What is faster... searching the string twice or creating > the Vector? I've gone with creating the Vector. Since split already works correctly, and doesn't do much more than checking if a , exists in the string, I believe this is the way to go. > > + while (g_hash_table_iter_next(&hashTableIter, &hashKey, &hashValue)) { > > + contentType += "; "; > > + contentType += static_cast<char*>(hashKey); > > + contentType += "="; > > + contentType += static_cast<char*>(hashValue); > > + } > > You could consider using StringBuilder here. And another thing. With HTTP > headers are like ASCII which makes your use of String(char*) okay, but maybe > write String() around it as well to highlight that we really want this. I have added the String()'s, but since I am not sure of the advantages of using StringBuilder here, when compared to simply using the + operator, I have left that out for the time being. Thanks! Created attachment 28944 [details]
use soup facilities to append parameters to the content type
WebCore/ChangeLog | 10 ++++++++++
.../platform/network/soup/ResourceHandleSoup.cpp | 10 ++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
Comment on attachment 28944 [details]
use soup facilities to append parameters to the content type
danw noticed that my work-around is not robust enough for parameters with spaces in their values; this patch uses the libsoup facilities, which handle these cases correctly, to append the parameters
Reopening bug because I posted a new, related patch. Comment on attachment 28944 [details]
use soup facilities to append parameters to the content type
Okay, didn't know this method, nice cleanup.
|