diff --git a/libsoup2.4/libsoup/soup-message-io.c b/libsoup2.4/libsoup/soup-message-io.c
index 53d20a3..a0bd3d3 100644
--- a/libsoup2.4/libsoup/soup-message-io.c
+++ b/libsoup2.4/libsoup/soup-message-io.c
@@ -211,6 +211,10 @@ io_disconnected (SoupSocket *sock, SoupMessage *msg)
  * %TRUE, it reads up until a blank line ("CRLF CRLF" or "LF LF").
  * Otherwise, it reads up until a single CRLF or LF.
  *
+ * As a special case, if EOF is encountered after a single LF,
+ * this is also considered as a blank line.  An extra CRLF is then
+ * appended at the end of read_meta_buf.
+ *
  * This function is used to read metadata, and read_body_chunk() is
  * used to read the message body contents.
  *
@@ -245,8 +249,17 @@ read_metadata (SoupMessage *msg, gboolean to_blank)
 			g_byte_array_append (io->read_meta_buf, read_buf, nread);
 			break;
 
-		case SOUP_SOCKET_ERROR:
 		case SOUP_SOCKET_EOF:
+			if (to_blank &&
+			    io->read_meta_buf->len > 1 &&
+			    io->read_meta_buf->data[io->read_meta_buf->len-1] == '\n') {
+				g_byte_array_append (io->read_meta_buf, "\r\n", 2);
+				return TRUE;
+			}
+			io_error (io->sock, msg, error);
+			return FALSE;
+
+		case SOUP_SOCKET_ERROR:
 			io_error (io->sock, msg, error);
 			return FALSE;
 
