aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-01-16 12:31:21 -0700
committerGravatar Brendan Taylor <whateley@gmail.com>2011-01-16 12:31:21 -0700
commit835f5d8d09b429a4776192dbe00be5ae20704b16 (patch)
tree8058b874f9528b0fe8ecf66745e93391f8fa19fb
parent63f77587bcc44c0edef74690d82555425d59d79a (diff)
don't crash when a download content-type can't be found
-rw-r--r--src/callbacks.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index 7b06873..fa2ed1f 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -825,16 +825,19 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat
g_object_get(download, "suggested-filename", &suggested_filename, NULL);
/* get the mimetype of the download */
- const gchar *content_type;
+ const gchar *content_type = NULL;
WebKitNetworkResponse *r = webkit_download_get_network_response(download);
/* downloads can be initiated from the context menu, in that case there is
no network response yet and trying to get one would crash. */
if(WEBKIT_IS_NETWORK_RESPONSE(r)) {
- SoupMessage *m = webkit_network_response_get_message(r);
- SoupMessageHeaders *h;
+ SoupMessage *m = webkit_network_response_get_message(r);
+ SoupMessageHeaders *h = NULL;
g_object_get(m, "response-headers", &h, NULL);
- content_type = soup_message_headers_get_one(h, "Content-Type");
- } else
+ if(h) /* some versions of libsoup don't have "response-headers" here */
+ content_type = soup_message_headers_get_one(h, "Content-Type");
+ }
+
+ if(!content_type)
content_type = "application/octet-stream";
/* get the filesize of the download, as given by the server.