/* RFC 2616 4.1 "servers SHOULD ignore any empty line(s)
* received where a Request-Line is expected."
*/
- while (*str == '\r' || *str == '\n') {
+ while ((*str == '\r' || *str == '\n') && len > 0) {
str++;
len--;
}
+ if (!len)
+ return SOUP_STATUS_BAD_REQUEST;
/* RFC 2616 19.3 "[servers] SHOULD accept any amount of SP or
* HT characters between [Request-Line] fields"
g_return_val_if_fail (str && *str, FALSE);
+ /* Workaround for broken servers that send extra line breaks
+ * after a response, which we then see prepended to the next
+ * response on that connection.
+ */
+ while ((*str == '\r' || *str == '\n') && len > 0) {
+ str++;
+ len--;
+ }
+ if (!len)
+ return FALSE;
+
if (!soup_headers_parse (str, len, headers))
return FALSE;
}
},
+ /* qv bug 602863 */
+ { "HTTP 1.1 response with leading line break",
+ "\nHTTP/1.1 200 ok\r\nFoo: bar\r\n", -1,
+ SOUP_HTTP_1_1, SOUP_STATUS_OK, "ok",
+ { { "Foo", "bar" },
+ { NULL } }
+ },
+
/*************************/
/*** INVALID RESPONSES ***/
/*************************/