aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-01-30 18:21:57 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-01-30 20:24:15 +0100
commit48c3bed43bbd9cee6e4f25d44aa3b251d34ccb72 (patch)
treead8fd6330ab3d8b4f675553fc177dbecd8d80276
parent1c9aaa0bac5129afec2dc1deb515054586244755 (diff)
http2: add CRLF when first data arrives
-rw-r--r--lib/http.h2
-rw-r--r--lib/http2.c18
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/http.h b/lib/http.h
index 460e928be..a32a71d78 100644
--- a/lib/http.h
+++ b/lib/http.h
@@ -157,7 +157,7 @@ struct http_conn {
size_t binlen; /* length of the binsettings data */
char *mem; /* points to a buffer in memory to store or read from */
size_t len; /* size of the buffer 'mem' points to */
- ssize_t nread; /* how much data that was sent/recv by the HTTP2 engine */
+ bool bodystarted;
#else
int unused; /* prevent a compiler warning */
#endif
diff --git a/lib/http2.c b/lib/http2.c
index 019518514..c4affe433 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -138,13 +138,21 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
infof(conn->data, "on_data_chunk_recv() "
"len = %u, stream = %x\n", len, stream_id);
+ if(!c->bodystarted) {
+ memcpy(c->mem, "\r\n", 2); /* signal end of headers */
+ c->mem += 2;
+ c->len -= 2;
+ c->bodystarted = TRUE;
+ }
+
if(len < c->len) {
memcpy(c->mem, data, len);
c->mem += len;
c->len -= len;
}
else {
- infof(conn->data, "EEEEEEK\n");
+ infof(conn->data, "EEEEEEK: %d > %d\n", len, c->len);
+ /* return NGHTTP2_ERR_PAUSE; */
}
return 0;
@@ -242,7 +250,6 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
c->mem[namelen + valuelen + 2]='\n';
c->mem[namelen + valuelen + 3]=0; /* to display this easier */
}
- infof(conn->data, "Got %s", c->mem);
c->mem += hlen;
c->len -= hlen;
@@ -366,7 +373,8 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
conn->proto.httpc.mem = mem;
conn->proto.httpc.len = len;
- infof(conn->data, "http2_recv\n");
+ infof(conn->data, "http2_recv: %d bytes buffer\n",
+ conn->proto.httpc.len);
for(;;) {
rc = Curl_read_plain(conn->sock[FIRSTSOCKET], inbuf, H2_BUFSIZE, &nread);
@@ -383,7 +391,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
*err = CURLE_RECV_ERROR;
return 0;
}
- infof(conn->data, "nread=%zd\n", nread);
+
if(!nread) {
*err = CURLE_RECV_ERROR;
return 0; /* TODO EOF? */
@@ -401,6 +409,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
/* Happens when NGHTTP2_ERR_PAUSE is returned from user callback */
break;
}
+ break;
}
return len - conn->proto.httpc.len;
}
@@ -427,6 +436,7 @@ int Curl_http2_switched(struct connectdata *conn)
conn->recv[FIRSTSOCKET] = http2_recv;
conn->send[FIRSTSOCKET] = http2_send;
infof(conn->data, "We have switched to HTTP2\n");
+ httpc->bodystarted = FALSE;
/* send the SETTINGS frame (again) */
rc = nghttp2_session_upgrade(httpc->h2, httpc->binsettings, httpc->binlen,