aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-01-30 05:04:02 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-01-30 05:04:02 +0000
commit169b2eeb94f7643229ac08fe305876530d40a680 (patch)
treec7e85f448b7389a61d4389d261b43a35cc4a3e82
parentf81d027f60f0c015ab227338f4a43737cbe84d2e (diff)
Fixes bug #669059. We now extract the Content-Type better and more accurate.
-rw-r--r--lib/transfer.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index e8cad9e3f..d977013b1 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -567,22 +567,29 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*start && isspace((int)*start);
start++);
- /* count all non-space letters following */
- for(end=start, len=0;
- *end && !isspace((int)*end);
- end++, len++);
-
- /* allocate memory of a cloned copy */
- if(data->info.contenttype)
- free(data->info.contenttype);
+ end = strchr(start, '\r');
+ if(!end)
+ end = strchr(start, '\n');
+
+ if(end) {
+ /* skip all trailing space letters */
+ for(; isspace(*end) && (end > start); end--);
+
+ /* get length of the type */
+ len = end-start+1;
- data->info.contenttype = malloc(len + 1);
- if (NULL == data->info.contenttype)
- return CURLE_OUT_OF_MEMORY;
+ /* allocate memory of a cloned copy */
+ if(data->info.contenttype)
+ free(data->info.contenttype);
+
+ data->info.contenttype = malloc(len + 1);
+ if (NULL == data->info.contenttype)
+ return CURLE_OUT_OF_MEMORY;
- /* copy the content-type string */
- memcpy(data->info.contenttype, start, len);
- data->info.contenttype[len] = 0; /* zero terminate */
+ /* copy the content-type string */
+ memcpy(data->info.contenttype, start, len);
+ data->info.contenttype[len] = 0; /* zero terminate */
+ }
}
else if((k->httpversion == 10) &&
conn->bits.httpproxy &&