summaryrefslogtreecommitdiff
path: root/libsoup
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2017-03-21 14:19:46 +0100
committerDan Winship <danw@gnome.org>2017-08-07 10:02:50 -0400
commit2177c522a46809be3eee15bf0864b8491c67467d (patch)
tree04c9c279469500a3b539fc084b7e2d5bdd133abd /libsoup
parent7aa41c2f6b2b159a2503cf02dc203cbf1493c4b7 (diff)
downloadlibsoup-2177c522a46809be3eee15bf0864b8491c67467d.tar.gz
soup-message-io: Do not fail when there's no empty line after headers
The spec says there should be an empty line (\r\n) between the response headers and the body. However, some servers don't include the empty line when the response doesn't have a body. This is causing several WebKit tests to fail, because some of the imported w3c tests do not include that empty line. Those tests pass in firefox, chromium and safari, so at least those other browsers allow that. https://bugzilla.gnome.org/show_bug.cgi?id=780352
Diffstat (limited to 'libsoup')
-rw-r--r--libsoup/soup-message-io.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index e893ec2a..fb505fa1 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -229,6 +229,8 @@ read_headers (SoupMessage *msg, gboolean blocking,
cancellable, error);
io->read_header_buf->len = old_len + MAX (nread, 0);
if (nread == 0) {
+ if (io->read_header_buf->len > 0)
+ break;
soup_message_set_status (msg, SOUP_STATUS_MALFORMED);
g_set_error_literal (error, G_IO_ERROR,
G_IO_ERROR_PARTIAL_INPUT,
@@ -241,27 +243,20 @@ read_headers (SoupMessage *msg, gboolean blocking,
if (nread == 1 && old_len >= 2 &&
!strncmp ((char *)io->read_header_buf->data +
io->read_header_buf->len - 2,
- "\n\n", 2))
+ "\n\n", 2)) {
+ io->read_header_buf->len--;
break;
- else if (nread == 2 && old_len >= 3 &&
+ } else if (nread == 2 && old_len >= 3 &&
!strncmp ((char *)io->read_header_buf->data +
io->read_header_buf->len - 3,
- "\n\r\n", 3))
+ "\n\r\n", 3)) {
+ io->read_header_buf->len -= 2;
break;
+ }
}
}
- /* We need to "rewind" io->read_header_buf back one line.
- * That SHOULD be two characters (CR LF), but if the
- * web server was stupid, it might only be one.
- */
- if (io->read_header_buf->len < 3 ||
- io->read_header_buf->data[io->read_header_buf->len - 2] == '\n')
- io->read_header_buf->len--;
- else
- io->read_header_buf->len -= 2;
io->read_header_buf->data[io->read_header_buf->len] = '\0';
-
return TRUE;
}