diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index 21e78d6..51f7be4 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -40,6 +40,7 @@ soup_headers_parse (const char *str, int len, SoupMessageHeaders *dest)
 	char *headers_copy, *name, *name_end, *value, *value_end;
 	char *eol, *sol, *p;
 	gboolean success = FALSE;
+	gboolean broken;
 
 	g_return_val_if_fail (str != NULL, FALSE);
 	g_return_val_if_fail (dest != NULL, FALSE);
@@ -47,8 +48,9 @@ soup_headers_parse (const char *str, int len, SoupMessageHeaders *dest)
 	/* RFC 2616 does allow NUL bytes in the headers, but httpbis
 	 * is changing that, and we can't deal with them anyway.
 	 */
-	if (memchr (str, '\0', len))
-		return FALSE;
+	broken = memchr (str, '\0', len) != NULL;
+	if (broken)
+		len = ((const char *) memchr (str, '\0', len)) - str;
 
 	/* As per RFC 2616 section 19.3, we treat '\n' as the
 	 * line terminator, and '\r', if it appears, merely as
@@ -92,8 +94,13 @@ soup_headers_parse (const char *str, int len, SoupMessageHeaders *dest)
 		 */
 		value = name_end + 1;
 		value_end = strchr (name, '\n');
-		if (!value_end)
-			goto done;
+		if (!value_end) {
+			if (broken) {
+				value_end = (char *) str + len - 1;
+			} else {
+				goto done;
+			}
+		}
 		while (*(value_end + 1) == ' ' || *(value_end + 1) == '\t') {
 			value_end = strchr (value_end + 1, '\n');
 			if (!value_end)
