Lines Matching refs:stream

159 static void h2_stream_hash_free(void *stream);
231 struct h2_stream_ctx *stream; in h2_stream_ctx_create() local
234 stream = calloc(1, sizeof(*stream)); in h2_stream_ctx_create()
235 if(!stream) in h2_stream_ctx_create()
238 stream->id = -1; in h2_stream_ctx_create()
239 Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp, in h2_stream_ctx_create()
241 Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); in h2_stream_ctx_create()
242 Curl_dynhds_init(&stream->resp_trailers, 0, DYN_HTTP_REQUEST); in h2_stream_ctx_create()
243 stream->resp_hds_len = 0; in h2_stream_ctx_create()
244 stream->bodystarted = FALSE; in h2_stream_ctx_create()
245 stream->status_code = -1; in h2_stream_ctx_create()
246 stream->closed = FALSE; in h2_stream_ctx_create()
247 stream->close_handled = FALSE; in h2_stream_ctx_create()
248 stream->error = NGHTTP2_NO_ERROR; in h2_stream_ctx_create()
249 stream->local_window_size = H2_STREAM_WINDOW_SIZE_INITIAL; in h2_stream_ctx_create()
250 stream->nrcvd_data = 0; in h2_stream_ctx_create()
251 return stream; in h2_stream_ctx_create()
254 static void free_push_headers(struct h2_stream_ctx *stream) in free_push_headers() argument
257 for(i = 0; i < stream->push_headers_used; i++) in free_push_headers()
258 free(stream->push_headers[i]); in free_push_headers()
259 Curl_safefree(stream->push_headers); in free_push_headers()
260 stream->push_headers_used = 0; in free_push_headers()
263 static void h2_stream_ctx_free(struct h2_stream_ctx *stream) in h2_stream_ctx_free() argument
265 Curl_bufq_free(&stream->sendbuf); in h2_stream_ctx_free()
266 Curl_h1_req_parse_free(&stream->h1); in h2_stream_ctx_free()
267 Curl_dynhds_free(&stream->resp_trailers); in h2_stream_ctx_free()
268 free_push_headers(stream); in h2_stream_ctx_free()
269 free(stream); in h2_stream_ctx_free()
272 static void h2_stream_hash_free(void *stream) in h2_stream_hash_free() argument
274 DEBUGASSERT(stream); in h2_stream_hash_free()
275 h2_stream_ctx_free((struct h2_stream_ctx *)stream); in h2_stream_hash_free()
295 struct h2_stream_ctx *stream, in cf_h2_update_local_win() argument
303 if(dwsize != stream->local_window_size) { in cf_h2_update_local_win()
305 ctx->h2, stream->id); in cf_h2_update_local_win()
308 stream->id, dwsize - wsize); in cf_h2_update_local_win()
311 "%s(%d)", stream->id, nghttp2_strerror(rv), rv); in cf_h2_update_local_win()
314 stream->local_window_size = dwsize; in cf_h2_update_local_win()
316 stream->id, dwsize - wsize); in cf_h2_update_local_win()
320 stream->id, dwsize); in cf_h2_update_local_win()
323 "%s(%d)", stream->id, nghttp2_strerror(rv), rv); in cf_h2_update_local_win()
326 stream->local_window_size = dwsize; in cf_h2_update_local_win()
328 stream->id, dwsize); in cf_h2_update_local_win()
338 struct h2_stream_ctx *stream, in cf_h2_update_local_win() argument
343 (void)stream; in cf_h2_update_local_win()
354 struct h2_stream_ctx *stream) in drain_stream() argument
360 if(!stream->closed && in drain_stream()
361 (!stream->body_eos || !Curl_bufq_is_empty(&stream->sendbuf))) in drain_stream()
363 if(stream->closed || (data->state.select_bits != bits)) { in drain_stream()
365 stream->id, bits); in drain_stream()
376 struct h2_stream_ctx *stream; in http2_data_setup() local
380 stream = H2_STREAM_CTX(ctx, data); in http2_data_setup()
381 if(stream) { in http2_data_setup()
382 *pstream = stream; in http2_data_setup()
386 stream = h2_stream_ctx_create(ctx); in http2_data_setup()
387 if(!stream) in http2_data_setup()
390 if(!Curl_hash_offt_set(&ctx->streams, data->mid, stream)) { in http2_data_setup()
391 h2_stream_ctx_free(stream); in http2_data_setup()
395 *pstream = stream; in http2_data_setup()
402 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in http2_data_done() local
405 if(!stream || !ctx->initialized) in http2_data_done()
411 (void)nghttp2_session_set_stream_user_data(ctx->h2, stream->id, NULL); in http2_data_done()
413 if(!stream->closed && stream->id > 0) { in http2_data_done()
416 stream->id); in http2_data_done()
417 stream->closed = TRUE; in http2_data_done()
418 stream->reset = TRUE; in http2_data_done()
420 stream->id, NGHTTP2_STREAM_CLOSED); in http2_data_done()
511 struct h2_stream_ctx *stream; in cf_h2_ctx_open() local
562 result = http2_data_setup(cf, data, &stream); in cf_h2_ctx_open()
565 DEBUGASSERT(stream); in cf_h2_ctx_open()
566 stream->id = 1; in cf_h2_ctx_open()
578 rc = nghttp2_session_set_stream_user_data(ctx->h2, stream->id, in cf_h2_ctx_open()
582 stream->id); in cf_h2_ctx_open()
820 struct h2_stream_ctx *stream; member
834 if(h->stream && num < h->stream->push_headers_used) in curl_pushheader_bynum()
835 return h->stream->push_headers[num]; in curl_pushheader_bynum()
845 struct h2_stream_ctx *stream; in curl_pushheader_byname() local
858 stream = h->stream; in curl_pushheader_byname()
859 if(!stream) in curl_pushheader_byname()
863 for(i = 0; i < stream->push_headers_used; i++) { in curl_pushheader_byname()
864 if(!strncmp(header, stream->push_headers[i], len)) { in curl_pushheader_byname()
866 if(stream->push_headers[i][len] != ':') in curl_pushheader_byname()
868 return &stream->push_headers[i][len + 1]; in curl_pushheader_byname()
957 struct h2_stream_ctx *stream; in push_promise() local
973 stream = H2_STREAM_CTX(ctx, data); in push_promise()
974 if(!stream) { in push_promise()
982 heads.stream = stream; in push_promise()
999 DEBUGASSERT(stream); in push_promise()
1003 stream->push_headers_used, &heads, in push_promise()
1008 free_push_headers(stream); in push_promise()
1056 struct h2_stream_ctx *stream, in h2_xfer_write_resp_hd() argument
1061 if(!stream->xfer_result) { in h2_xfer_write_resp_hd()
1062 stream->xfer_result = Curl_xfer_write_resp_hd(data, buf, blen, eos); in h2_xfer_write_resp_hd()
1063 if(!stream->xfer_result && !eos) in h2_xfer_write_resp_hd()
1064 stream->xfer_result = cf_h2_update_local_win(cf, data, stream, FALSE); in h2_xfer_write_resp_hd()
1065 if(stream->xfer_result) in h2_xfer_write_resp_hd()
1067 stream->id, stream->xfer_result, blen); in h2_xfer_write_resp_hd()
1073 struct h2_stream_ctx *stream, in h2_xfer_write_resp() argument
1078 if(!stream->xfer_result) in h2_xfer_write_resp()
1079 stream->xfer_result = Curl_xfer_write_resp(data, buf, blen, eos); in h2_xfer_write_resp()
1080 if(!stream->xfer_result && !eos) in h2_xfer_write_resp()
1081 stream->xfer_result = cf_h2_update_local_win(cf, data, stream, FALSE); in h2_xfer_write_resp()
1083 if(stream->xfer_result) { in h2_xfer_write_resp()
1087 stream->id, stream->xfer_result, blen); in h2_xfer_write_resp()
1088 nghttp2_submit_rst_stream(ctx->h2, 0, stream->id, in h2_xfer_write_resp()
1098 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in on_stream_frame() local
1102 if(!stream) { in on_stream_frame()
1112 ctx->h2, stream->id), in on_stream_frame()
1114 ctx->h2, stream->id)); in on_stream_frame()
1116 if(!stream->bodystarted) { in on_stream_frame()
1126 if(stream->bodystarted) { in on_stream_frame()
1135 if(stream->status_code == -1) in on_stream_frame()
1139 if(stream->status_code / 100 != 1) in on_stream_frame()
1140 stream->bodystarted = TRUE; in on_stream_frame()
1142 stream->status_code = -1; in on_stream_frame()
1144 h2_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"), stream->closed); in on_stream_frame()
1146 if(stream->status_code / 100 != 1) { in on_stream_frame()
1147 stream->resp_hds_complete = TRUE; in on_stream_frame()
1149 drain_stream(cf, data, stream); in on_stream_frame()
1168 stream->closed = TRUE; in on_stream_frame()
1170 stream->reset = TRUE; in on_stream_frame()
1172 drain_stream(cf, data, stream); in on_stream_frame()
1175 if(CURL_WANT_SEND(data) && Curl_bufq_is_empty(&stream->sendbuf)) { in on_stream_frame()
1177 drain_stream(cf, data, stream); in on_stream_frame()
1179 else if(!Curl_bufq_is_empty(&stream->sendbuf)) { in on_stream_frame()
1181 rv = nghttp2_session_resume_data(ctx->h2, stream->id); in on_stream_frame()
1191 if(!stream->closed && !stream->body_eos && in on_stream_frame()
1192 ((stream->status_code >= 400) || (stream->status_code < 200))) { in on_stream_frame()
1198 stream_id, stream->status_code); in on_stream_frame()
1200 stream->id, NGHTTP2_STREAM_CLOSED); in on_stream_frame()
1201 stream->closed = TRUE; in on_stream_frame()
1203 drain_stream(cf, data, stream); in on_stream_frame()
1345 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in on_frame_recv() local
1346 if(stream) in on_frame_recv()
1347 drain_stream(cf, data, stream); in on_frame_recv()
1383 struct h2_stream_ctx *stream; in on_data_chunk_recv() local
1403 stream = H2_STREAM_CTX(ctx, data_s); in on_data_chunk_recv()
1404 if(!stream) in on_data_chunk_recv()
1407 h2_xfer_write_resp(cf, data_s, stream, (char *)mem, len, FALSE); in on_data_chunk_recv()
1410 stream->nrcvd_data += (curl_off_t)len; in on_data_chunk_recv()
1420 struct h2_stream_ctx *stream; in on_stream_close() local
1442 stream = H2_STREAM_CTX(ctx, data_s); in on_stream_close()
1443 if(!stream) { in on_stream_close()
1449 stream->closed = TRUE; in on_stream_close()
1450 stream->error = error_code; in on_stream_close()
1451 if(stream->error) { in on_stream_close()
1452 stream->reset = TRUE; in on_stream_close()
1455 if(stream->error) in on_stream_close()
1460 drain_stream(cf, data_s, stream); in on_stream_close()
1477 struct h2_stream_ctx *stream; in on_begin_headers() local
1490 stream = H2_STREAM_CTX(ctx, data_s); in on_begin_headers()
1491 if(!stream || !stream->bodystarted) { in on_begin_headers()
1507 struct h2_stream_ctx *stream; in on_header() local
1522 stream = H2_STREAM_CTX(ctx, data_s); in on_header()
1523 if(!stream) { in on_header()
1558 if(!stream->push_headers) { in on_header()
1559 stream->push_headers_alloc = 10; in on_header()
1560 stream->push_headers = malloc(stream->push_headers_alloc * in on_header()
1562 if(!stream->push_headers) in on_header()
1564 stream->push_headers_used = 0; in on_header()
1566 else if(stream->push_headers_used == in on_header()
1567 stream->push_headers_alloc) { in on_header()
1569 if(stream->push_headers_alloc > 1000) { in on_header()
1572 free_push_headers(stream); in on_header()
1575 stream->push_headers_alloc *= 2; in on_header()
1576 headp = realloc(stream->push_headers, in on_header()
1577 stream->push_headers_alloc * sizeof(char *)); in on_header()
1579 free_push_headers(stream); in on_header()
1582 stream->push_headers = headp; in on_header()
1586 stream->push_headers[stream->push_headers_used++] = h; in on_header()
1590 if(stream->bodystarted) { in on_header()
1593 stream->id, (int)namelen, name, (int)valuelen, value); in on_header()
1594 result = Curl_dynhds_add(&stream->resp_trailers, in on_header()
1607 result = Curl_http_decode_status(&stream->status_code, in on_header()
1612 stream->status_code); in on_header()
1623 h2_xfer_write_resp_hd(cf, data_s, stream, Curl_dyn_ptr(&ctx->scratch), in on_header()
1632 stream->id, stream->status_code); in on_header()
1648 h2_xfer_write_resp_hd(cf, data_s, stream, Curl_dyn_ptr(&ctx->scratch), in on_header()
1657 stream->id, (int)namelen, name, (int)valuelen, value); in on_header()
1672 struct h2_stream_ctx *stream = NULL; in req_body_read_callback() local
1689 stream = H2_STREAM_CTX(ctx, data_s); in req_body_read_callback()
1690 if(!stream) in req_body_read_callback()
1693 nread = Curl_bufq_read(&stream->sendbuf, buf, length, &result); in req_body_read_callback()
1701 stream_id, length, stream->body_eos, nread, result); in req_body_read_callback()
1703 if(stream->body_eos && Curl_bufq_is_empty(&stream->sendbuf)) { in req_body_read_callback()
1766 struct h2_stream_ctx *stream, in http2_handle_stream_close() argument
1771 if(stream->error == NGHTTP2_REFUSED_STREAM) { in http2_handle_stream_close()
1773 "connection", stream->id); in http2_handle_stream_close()
1779 else if(stream->error != NGHTTP2_NO_ERROR) { in http2_handle_stream_close()
1780 if(stream->resp_hds_complete && data->req.no_body) { in http2_handle_stream_close()
1783 stream->id, nghttp2_http2_strerror(stream->error), in http2_handle_stream_close()
1784 stream->error); in http2_handle_stream_close()
1785 stream->close_handled = TRUE; in http2_handle_stream_close()
1790 stream->id, nghttp2_http2_strerror(stream->error), in http2_handle_stream_close()
1791 stream->error); in http2_handle_stream_close()
1795 else if(stream->reset) { in http2_handle_stream_close()
1796 failf(data, "HTTP/2 stream %u was reset", stream->id); in http2_handle_stream_close()
1801 if(!stream->bodystarted) { in http2_handle_stream_close()
1804 stream->id); in http2_handle_stream_close()
1809 if(Curl_dynhds_count(&stream->resp_trailers)) { in http2_handle_stream_close()
1816 for(i = 0; i < Curl_dynhds_count(&stream->resp_trailers); ++i) { in http2_handle_stream_close()
1817 e = Curl_dynhds_getn(&stream->resp_trailers, i); in http2_handle_stream_close()
1838 stream->close_handled = TRUE; in http2_handle_stream_close()
1890 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in h2_progress_egress() local
1893 if(stream && stream->id > 0 && in h2_progress_egress()
1901 CURL_TRC_CF(data, cf, "[%d] Queuing PRIORITY", stream->id); in h2_progress_egress()
1902 DEBUGASSERT(stream->id != -1); in h2_progress_egress()
1904 stream->id, &pri_spec); in h2_progress_egress()
1928 struct h2_stream_ctx *stream, in stream_recv() argument
1936 if(stream->xfer_result) { in stream_recv()
1937 CURL_TRC_CF(data, cf, "[%d] xfer write failed", stream->id); in stream_recv()
1938 *err = stream->xfer_result; in stream_recv()
1941 else if(stream->closed) { in stream_recv()
1942 CURL_TRC_CF(data, cf, "[%d] returning CLOSE", stream->id); in stream_recv()
1943 nread = http2_handle_stream_close(cf, data, stream, err); in stream_recv()
1945 else if(stream->reset || in stream_recv()
1947 (ctx->rcvd_goaway && ctx->remote_max_sid < stream->id)) { in stream_recv()
1948 CURL_TRC_CF(data, cf, "[%d] returning ERR", stream->id); in stream_recv()
1955 stream->id, len, nread, *err); in stream_recv()
1964 struct h2_stream_ctx *stream; in h2_progress_ingress() local
1980 stream = H2_STREAM_CTX(ctx, data); in h2_progress_ingress()
1981 if(stream && (stream->closed || !data_max_bytes)) { in h2_progress_ingress()
1987 drain_stream(cf, data, stream); in h2_progress_ingress()
2029 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_recv() local
2034 if(!stream) { in cf_h2_recv()
2047 nread = stream_recv(cf, data, stream, buf, len, err); in cf_h2_recv()
2056 nread = stream_recv(cf, data, stream, buf, len, err); in cf_h2_recv()
2064 if(stream->resp_hds_len >= data_consumed) { in cf_h2_recv()
2065 stream->resp_hds_len -= data_consumed; /* no DATA */ in cf_h2_recv()
2068 if(stream->resp_hds_len) { in cf_h2_recv()
2069 data_consumed -= stream->resp_hds_len; in cf_h2_recv()
2070 stream->resp_hds_len = 0; in cf_h2_recv()
2073 nghttp2_session_consume(ctx->h2, stream->id, data_consumed); in cf_h2_recv()
2077 if(stream->closed) { in cf_h2_recv()
2078 CURL_TRC_CF(data, cf, "[%d] DRAIN closed stream", stream->id); in cf_h2_recv()
2079 drain_stream(cf, data, stream); in cf_h2_recv()
2090 drain_stream(cf, data, stream); in cf_h2_recv()
2098 stream->id, len, nread, *err, in cf_h2_recv()
2100 ctx->h2, stream->id), in cf_h2_recv()
2102 ctx->h2, stream->id), in cf_h2_recv()
2112 struct h2_stream_ctx *stream, in cf_h2_body_send() argument
2119 if(stream->closed) { in cf_h2_body_send()
2120 if(stream->resp_hds_complete) { in cf_h2_body_send()
2127 "on closed stream with response", stream->id); in cf_h2_body_send()
2129 stream->body_eos = TRUE; in cf_h2_body_send()
2134 infof(data, "stream %u closed", stream->id); in cf_h2_body_send()
2139 nwritten = Curl_bufq_write(&stream->sendbuf, buf, blen, err); in cf_h2_body_send()
2144 stream->body_eos = TRUE; in cf_h2_body_send()
2146 if(eos || !Curl_bufq_is_empty(&stream->sendbuf)) { in cf_h2_body_send()
2148 int rv = nghttp2_session_resume_data(ctx->h2, stream->id); in cf_h2_body_send()
2163 struct h2_stream_ctx *stream = NULL; in h2_submit() local
2175 *err = http2_data_setup(cf, data, &stream); in h2_submit()
2181 nwritten = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, 0, err); in h2_submit()
2184 if(!stream->h1.done) { in h2_submit()
2188 DEBUGASSERT(stream->h1.req); in h2_submit()
2190 *err = Curl_http_req_to_h2(&h2_headers, stream->h1.req, data); in h2_submit()
2196 Curl_h1_req_parse_free(&stream->h1); in h2_submit()
2253 stream->id = stream_id; in h2_submit()
2259 ssize_t n = cf_h2_body_send(cf, data, stream, body, bodylen, eos, err); in h2_submit()
2273 stream ? stream->id : -1, nwritten, *err); in h2_submit()
2275 *pstream = stream; in h2_submit()
2285 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_send() local
2292 if(!stream || stream->id == -1) { in cf_h2_send()
2293 nwritten = h2_submit(&stream, cf, data, buf, len, eos, err); in cf_h2_send()
2297 DEBUGASSERT(stream); in cf_h2_send()
2299 else if(stream->body_eos) { in cf_h2_send()
2305 nwritten = cf_h2_body_send(cf, data, stream, buf, 0, eos, err); in cf_h2_send()
2307 stream->id, nwritten, *err, eos); in cf_h2_send()
2314 nwritten = cf_h2_body_send(cf, data, stream, buf, len, eos, err); in cf_h2_send()
2316 stream->id, len, nwritten, *err, eos); in cf_h2_send()
2325 if(stream && stream->closed) { in cf_h2_send()
2326 infof(data, "stream %u closed", stream->id); in cf_h2_send()
2340 if(stream->closed) { in cf_h2_send()
2341 nwritten = http2_handle_stream_close(cf, data, stream, err); in cf_h2_send()
2351 if(stream) { in cf_h2_send()
2355 stream->id, len, nwritten, *err, in cf_h2_send()
2356 stream->body_eos, in cf_h2_send()
2358 ctx->h2, stream->id), in cf_h2_send()
2360 Curl_bufq_len(&stream->sendbuf), in cf_h2_send()
2378 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_flush() local
2383 if(stream && !Curl_bufq_is_empty(&stream->sendbuf)) { in cf_h2_flush()
2385 int rv = nghttp2_session_resume_data(ctx->h2, stream->id); in cf_h2_flush()
2395 if(stream) { in cf_h2_flush()
2399 stream->id, result, in cf_h2_flush()
2401 ctx->h2, stream->id), in cf_h2_flush()
2403 Curl_bufq_len(&stream->sendbuf), in cf_h2_flush()
2431 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_adjust_pollset() local
2436 s_exhaust = want_send && stream && stream->id >= 0 && in cf_h2_adjust_pollset()
2438 stream->id); in cf_h2_adjust_pollset()
2596 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in http2_data_pause() local
2599 if(ctx && ctx->h2 && stream) { in http2_data_pause()
2600 CURLcode result = cf_h2_update_local_win(cf, data, stream, pause); in http2_data_pause()
2613 drain_stream(cf, data, stream); in http2_data_pause()
2616 CURL_TRC_CF(data, cf, "[%d] stream now %spaused", stream->id, in http2_data_pause()
2658 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_data_pending() local
2661 || (stream && !Curl_bufq_is_empty(&stream->sendbuf)))) in cf_h2_data_pending()
2718 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_query() local
2719 *pres1 = stream ? (int)stream->error : 0; in cf_h2_query()
2723 struct h2_stream_ctx *stream = H2_STREAM_CTX(ctx, data); in cf_h2_query() local
2725 (stream && !Curl_bufq_is_empty(&stream->sendbuf))) { in cf_h2_query()