diff --git a/lib/http2.c b/lib/http2.c index e9eb81180..789f76a85 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -831,7 +831,22 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, return ncopy; } - if(stream->data) { + infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n", + len, mem, stream->stream_id); + + if(data->state.drain) { + DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n", + stream->memlen, stream->stream_id, + stream->mem, mem)); + if(mem != stream->mem) { + /* if we didn't get the same buffer this time, we must move the data to + the beginning */ + memmove(mem, stream->mem, stream->memlen); + stream->len = len - stream->memlen; + stream->mem = mem; + } + } + else if(stream->data) { nread = MIN(len, stream->datalen); memcpy(mem, stream->data, nread); @@ -851,22 +866,6 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, (int)nread); return nread; } - - infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n", - len, mem, stream->stream_id); - - if(data->state.drain) { - DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n", - stream->memlen, stream->stream_id, - stream->mem, mem)); - if(mem != stream->mem) { - /* if we didn't get the same buffer this time, we must move the data to - the beginning */ - memmove(mem, stream->mem, stream->memlen); - stream->len = len - stream->memlen; - stream->mem = mem; - } - } else if(httpc->pause_stream_id) { /* If a stream paused nghttp2_session_mem_recv previously, and has not processed all data, it still refers to the buffer in