Index: uspace/lib/http/src/headers.c
===================================================================
--- uspace/lib/http/src/headers.c	(revision fc3d4fd50aa9d132c9cadad4795d9b29511d59cc)
+++ uspace/lib/http/src/headers.c	(revision 9eb1ff5d8638a1ce98e59a7f0b7a667dc2e02a0a)
@@ -146,6 +146,7 @@
 			continue;
 		
-		rc = recv_discard(rb, (c == '\r' ? '\n' : '\r'));
-		if (rc < 0)
+		size_t nrecv;
+		rc = recv_discard(rb, (c == '\r' ? '\n' : '\r'), &nrecv);
+		if (rc != EOK)
 			return rc;
 		
Index: uspace/lib/http/src/http.c
===================================================================
--- uspace/lib/http/src/http.c	(revision fc3d4fd50aa9d132c9cadad4795d9b29511d59cc)
+++ uspace/lib/http/src/http.c	(revision 9eb1ff5d8638a1ce98e59a7f0b7a667dc2e02a0a)
@@ -47,15 +47,10 @@
 #include <http/receive-buffer.h>
 
-static ssize_t http_receive(void *client_data, void *buf, size_t buf_size)
+static int http_receive(void *client_data, void *buf, size_t buf_size,
+    size_t *nrecv)
 {
 	http_t *http = client_data;
-	size_t nrecv;
-	int rc;
 
-	rc = tcp_conn_recv_wait(http->conn, buf, buf_size, &nrecv);
-	if (rc != EOK)
-		return rc;
-
-	return nrecv;
+	return tcp_conn_recv_wait(http->conn, buf, buf_size, nrecv);
 }
 
Index: uspace/lib/http/src/receive-buffer.c
===================================================================
--- uspace/lib/http/src/receive-buffer.c	(revision fc3d4fd50aa9d132c9cadad4795d9b29511d59cc)
+++ uspace/lib/http/src/receive-buffer.c	(revision 9eb1ff5d8638a1ce98e59a7f0b7a667dc2e02a0a)
@@ -61,7 +61,9 @@
 }
 
-static ssize_t dummy_receive(void *unused, void *buf, size_t buf_size)
-{
-	return 0;
+static int dummy_receive(void *unused, void *buf, size_t buf_size,
+    size_t *nrecv)
+{
+	*nrecv = 0;
+	return EOK;
 }
 
@@ -167,9 +169,10 @@
 		}
 		
-		ssize_t rc = rb->receive(rb->client_data, rb->buffer + rb->in, free);
-		if (rc <= 0)
+		size_t nrecv;
+		int rc = rb->receive(rb->client_data, rb->buffer + rb->in, free, &nrecv);
+		if (rc != EOK)
 			return rc;
 		
-		rb->in = rc;
+		rb->in = nrecv;
 	}
 	
@@ -180,21 +183,24 @@
 }
 
-ssize_t recv_buffer(receive_buffer_t *rb, char *buf, size_t buf_size)
-{
-	/* Flush any buffered data*/
+int recv_buffer(receive_buffer_t *rb, char *buf, size_t buf_size,
+    size_t *nrecv)
+{
+	/* Flush any buffered data */
 	if (rb->out != rb->in) {
 		size_t size = min(rb->in - rb->out, buf_size);
 		memcpy(buf, rb->buffer + rb->out, size);
 		rb->out += size;
-		return size;
-	}
-	
-	return rb->receive(rb->client_data, buf, buf_size);
+		*nrecv = size;
+		return EOK;
+	}
+	
+	return rb->receive(rb->client_data, buf, buf_size, nrecv);
 }
 
 /** Receive a character and if it is c, discard it from input buffer
- * @return number of characters discarded (0 or 1) or negative error code
- */
-ssize_t recv_discard(receive_buffer_t *rb, char discard)
+ * @param ndisc Place to store number of characters discarded
+ * @return EOK or error code
+ */
+int recv_discard(receive_buffer_t *rb, char discard, size_t *ndisc)
 {
 	char c = 0;
@@ -202,34 +208,39 @@
 	if (rc != EOK)
 		return rc;
-	if (c != discard)
-		return 0;
+	if (c != discard) {
+		*ndisc = 0;
+		return EOK;
+	}
 	rc = recv_char(rb, &c, true);
 	if (rc != EOK)
 		return rc;
-	return 1;
+	*ndisc = 1;
+	return EOK;
 }
 
 /** Receive a prefix of constant string discard and return number of bytes read
- * @return number of characters discarded or negative error code
- */
-ssize_t recv_discard_str(receive_buffer_t *rb, const char *discard)
+ * @param ndisc Place to store number of characters discarded
+ * @return EOK or error code
+ */
+int recv_discard_str(receive_buffer_t *rb, const char *discard, size_t *ndisc)
 {
 	size_t discarded = 0;
 	while (*discard) {
-		ssize_t rc = recv_discard(rb, *discard);
-		if (rc < 0)
-			return rc;
-		if (rc == 0)
+		size_t nd;
+		int rc = recv_discard(rb, *discard, &nd);
+		if (rc != EOK)
+			return rc;
+		if (nd == 0)
 			break;
-		discarded++;
+		discarded += nd;
 		discard++;
 	}
-	return discarded;
-}
-
-ssize_t recv_while(receive_buffer_t *rb, char_class_func_t class)
-{
-	size_t received = 0;
-	
+
+	*ndisc = discarded;
+	return EOK;
+}
+
+int recv_while(receive_buffer_t *rb, char_class_func_t class)
+{
 	while (true) {
 		char c = 0;
@@ -244,17 +255,16 @@
 		if (rc != EOK)
 			return rc;
-		
-		received++;
-	}
-	
-	return received;
+	}
+	
+	return EOK;
 }
 
 /** Receive an end of line, either CR, LF, CRLF or LFCR
  *
- * @return number of bytes read (0 if no newline is present in the stream)
- *         or negative error code
- */
-ssize_t recv_eol(receive_buffer_t *rb)
+ * @param nrecv Place to store number of bytes received (zero if
+ *              no newline is present in the stream)
+ * @return EOK on success or error code
+ */
+int recv_eol(receive_buffer_t *rb, size_t *nrecv)
 {
 	char c = 0;
@@ -263,6 +273,8 @@
 		return rc;
 	
-	if (c != '\r' && c != '\n')
-		return 0;
+	if (c != '\r' && c != '\n') {
+		*nrecv = 0;
+		return EOK;
+	}
 	
 	rc = recv_char(rb, &c, true);
@@ -270,15 +282,18 @@
 		return rc;
 	
-	ssize_t rc2 = recv_discard(rb, (c == '\r' ? '\n' : '\r'));
-	if (rc2 < 0)
-		return rc2;
-	
-	return 1 + rc2;
+	size_t nr;
+	rc = recv_discard(rb, (c == '\r' ? '\n' : '\r'), &nr);
+	if (rc != EOK)
+		return rc;
+	
+	*nrecv = 1 + nr;
+	return EOK;
 }
 
 /* Receive a single line */
-ssize_t recv_line(receive_buffer_t *rb, char *line, size_t size)
+int recv_line(receive_buffer_t *rb, char *line, size_t size, size_t *nrecv)
 {
 	size_t written = 0;
+	size_t nr;
 	
 	while (written < size) {
@@ -288,12 +303,19 @@
 			return rc;
 		if (c == '\n') {
-			recv_discard(rb, '\r');
+			rc = recv_discard(rb, '\r', &nr);
+			if (rc != EOK)
+				return rc;
+
 			line[written++] = 0;
-			return written;
+			*nrecv = written;
+			return EOK;
 		}
 		else if (c == '\r') {
-			recv_discard(rb, '\n');
+			rc = recv_discard(rb, '\n', &nr);
+			if (rc != EOK)
+				return rc;
 			line[written++] = 0;
-			return written;
+			*nrecv = written;
+			return EOK;
 		}
 		line[written++] = c;
Index: uspace/lib/http/src/response.c
===================================================================
--- uspace/lib/http/src/response.c	(revision fc3d4fd50aa9d132c9cadad4795d9b29511d59cc)
+++ uspace/lib/http/src/response.c	(revision 9eb1ff5d8638a1ce98e59a7f0b7a667dc2e02a0a)
@@ -96,8 +96,9 @@
 static int expect(receive_buffer_t *rb, const char *expect)
 {
-	int rc = recv_discard_str(rb, expect);
-	if (rc < 0)
-		return rc;
-	if ((size_t) rc < str_length(expect))
+	size_t ndisc;
+	int rc = recv_discard_str(rb, expect, &ndisc);
+	if (rc != EOK)
+		return rc;
+	if (ndisc < str_length(expect))
 		return HTTP_EPARSE;
 	return EOK;
@@ -168,8 +169,9 @@
 	recv_unmark(rb, &msg_end);
 	
-	rc = recv_eol(rb);
-	if (rc == 0)
+	size_t nrecv;
+	rc = recv_eol(rb, &nrecv);
+	if (rc == EOK && nrecv == 0)
 		rc = HTTP_EPARSE;
-	if (rc < 0) {
+	if (rc != EOK) {
 		free(message);
 		return rc;
@@ -204,8 +206,9 @@
 		goto error;
 	
-	rc = recv_eol(rb);
-	if (rc == 0)
+	size_t nrecv;
+	rc = recv_eol(rb, &nrecv);
+	if (rc == EOK && nrecv == 0)
 		rc = HTTP_EPARSE;
-	if (rc < 0)
+	if (rc != EOK)
 		goto error;
 	
