Lines Matching refs:stream

80 /* A stream window is the maximum amount we need to buffer for
86 /* The pool keeps spares around and half of a full stream windows
88 * The benefit of the pool is that stream buffer to not keep
132 size_t max_stream_window; /* max flow window for one stream */
143 * All about the H3 internals of a stream
153 uint64_t error3; /* HTTP/3 stream error code */
157 bool closed; /* TRUE on stream close */
158 bool reset; /* TRUE on stream reset */
159 bool send_closed; /* stream is local closed */
160 BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */
174 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
181 if(stream)
184 stream = calloc(1, sizeof(*stream));
185 if(!stream)
188 stream->id = -1;
190 Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp,
192 stream->sendbuf_len_in_flight = 0;
195 Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp,
197 stream->recv_buf_nonflow = 0;
198 Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN);
200 H3_STREAM_LCTX(data) = stream;
207 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
210 if(stream) {
211 CURL_TRC_CF(data, cf, "[%"PRId64"] easy handle is done", stream->id);
212 if(ctx->h3conn && !stream->closed) {
213 nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream->id);
214 nghttp3_conn_close_stream(ctx->h3conn, stream->id,
216 nghttp3_conn_set_stream_user_data(ctx->h3conn, stream->id, NULL);
217 ngtcp2_conn_set_stream_user_data(ctx->qconn, stream->id, NULL);
218 stream->closed = TRUE;
221 Curl_bufq_free(&stream->sendbuf);
222 Curl_bufq_free(&stream->recvbuf);
223 Curl_h1_req_parse_free(&stream->h1);
224 free(stream);
253 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
258 if(stream && stream->upload_left && !stream->send_closed)
394 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
397 if(!stream)
401 if(stream->recv_buf_nonflow) {
402 if(consumed >= stream->recv_buf_nonflow) {
403 consumed -= stream->recv_buf_nonflow;
404 stream->recv_buf_nonflow = 0;
407 stream->recv_buf_nonflow -= consumed;
413 stream->id, consumed);
414 ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id,
440 CURL_TRC_CF(cdata, cf, "[%" PRId64 "] nghttp3 error on stream not "
492 /* stream is closed... */
571 struct h3_stream_ctx *stream;
582 stream = H3_STREAM_CTX(s_data);
583 if(stream && stream->quic_flow_blocked) {
585 stream->quic_flow_blocked = FALSE;
752 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
759 s_exhaust = want_send && stream && stream->id >= 0 &&
760 stream->quic_flow_blocked;
776 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
781 if(!stream)
784 stream->closed = TRUE;
785 stream->error3 = app_error_code;
786 if(stream->error3 != NGHTTP3_H3_NO_ERROR) {
787 stream->reset = TRUE;
788 stream->send_closed = TRUE;
790 stream->id, stream->error3);
793 CURL_TRC_CF(data, cf, "[%" PRId64 "] CLOSED", stream->id);
809 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
814 if(!stream) {
817 nwritten = Curl_bufq_write(&stream->recvbuf, mem, memlen, &result);
823 stream->recv_buf_nonflow += (size_t)nwritten;
840 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
846 if(!stream)
852 stream->id, buflen, result);
855 CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu", stream->id, buflen);
869 /* nghttp3 has consumed bytes on the QUIC stream and we need to
881 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
888 if(!stream)
897 stream_id, stream->status_code);
898 if(stream->status_code / 100 != 1) {
899 stream->resp_hds_complete = TRUE;
914 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
923 if(!stream)
930 result = Curl_http_decode_status(&stream->status_code,
935 stream->status_code);
1086 struct h3_stream_ctx *stream,
1092 if(stream->reset) {
1094 "HTTP/3 stream %" PRId64 " reset by server", stream->id);
1095 *err = stream->resp_hds_complete? CURLE_PARTIAL_FILE : CURLE_HTTP3;
1098 else if(!stream->resp_hds_complete) {
1100 "HTTP/3 stream %" PRId64 " was closed cleanly, but before getting"
1102 stream->id);
1113 /* incoming data frames on the h3 stream */
1118 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1134 if(!stream) {
1139 if(!Curl_bufq_is_empty(&stream->recvbuf)) {
1140 nread = Curl_bufq_read(&stream->recvbuf,
1144 "-> %zd, %d", stream->id, len, nread, *err);
1157 if(nread < 0 && !Curl_bufq_is_empty(&stream->recvbuf)) {
1158 nread = Curl_bufq_read(&stream->recvbuf,
1162 "-> %zd, %d", stream->id, len, nread, *err);
1172 if(stream->closed) {
1173 nread = recv_closed_stream(cf, data, stream, err);
1193 stream? stream->id : -1, len, nread, *err);
1204 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1208 if(!stream)
1213 if(datalen >= (uint64_t)stream->sendbuf_len_in_flight)
1214 skiplen = stream->sendbuf_len_in_flight;
1217 Curl_bufq_skip(&stream->sendbuf, skiplen);
1218 stream->sendbuf_len_in_flight -= skiplen;
1221 if(!stream->sendbuf_len_in_flight) {
1238 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1247 if(!stream)
1256 if(stream->sendbuf_len_in_flight < Curl_bufq_len(&stream->sendbuf)) {
1259 Curl_bufq_peek_at(&stream->sendbuf,
1260 stream->sendbuf_len_in_flight,
1263 stream->sendbuf_len_in_flight += vec[nvecs].len;
1270 if(nwritten > 0 && stream->upload_left != -1)
1271 stream->upload_left -= nwritten;
1275 if(stream->upload_left == 0) {
1277 stream->send_closed = TRUE;
1282 stream->id);
1289 stream->id, (int)nvecs,
1291 nwritten, Curl_bufq_len(&stream->sendbuf),
1292 stream->upload_left);
1306 struct h3_stream_ctx *stream = NULL;
1321 stream = H3_STREAM_CTX(data);
1322 DEBUGASSERT(stream);
1323 if(!stream) {
1328 nwritten = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, 0, err);
1331 if(!stream->h1.done) {
1335 DEBUGASSERT(stream->h1.req);
1337 *err = Curl_http_req_to_h2(&h2_headers, stream->h1.req, data);
1343 Curl_h1_req_parse_free(&stream->h1);
1362 rc = ngtcp2_conn_open_bidi_stream(ctx->qconn, &stream->id, data);
1376 stream->upload_left = data->state.infilesize;
1379 stream->upload_left = -1; /* unknown */
1383 stream->upload_left = 0; /* no request body */
1387 stream->send_closed = (stream->upload_left == 0);
1388 if(!stream->send_closed) {
1393 rc = nghttp3_conn_submit_request(ctx->h3conn, stream->id,
1399 "connection is closing", stream->id);
1403 stream->id, rc, ngtcp2_strerror(rc));
1412 infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s",
1413 stream->id, data->state.url);
1415 infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->id,
1431 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1450 if(!stream || stream->id < 0) {
1453 CURL_TRC_CF(data, cf, "failed to open stream -> %d", *err);
1456 stream = H3_STREAM_CTX(data);
1458 else if(stream->upload_blocked_len) {
1461 DEBUGASSERT(len >= stream->upload_blocked_len);
1462 if(len < stream->upload_blocked_len) {
1470 sent = (ssize_t)stream->upload_blocked_len;
1471 stream->upload_blocked_len = 0;
1473 else if(stream->closed) {
1474 if(stream->resp_hds_complete) {
1475 /* Server decided to close the stream after having sent us a final
1481 "on closed stream with response", stream->id);
1487 "-> stream closed", stream->id, len);
1493 sent = Curl_bufq_write(&stream->sendbuf, buf, len, err);
1496 stream->id, len, sent, *err);
1501 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id);
1510 if(stream && sent > 0 && stream->sendbuf_len_in_flight) {
1514 stream->upload_blocked_len = sent;
1516 "%zu bytes in flight -> EGAIN", stream->id, len,
1517 stream->sendbuf_len_in_flight);
1529 stream? stream->id : -1, len, sent, *err);
1688 struct h3_stream_ctx *stream = H3_STREAM_CTX(x->data);
1693 DEBUGASSERT(stream);
1694 if(stream)
1695 stream->quic_flow_blocked = TRUE;
1705 /* ngtcp2 wants to send more. update the flow of the stream whose data
1860 const struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1862 return stream && !Curl_bufq_is_empty(&stream->recvbuf);
1902 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1903 if(stream && !stream->send_closed) {
1904 stream->send_closed = TRUE;
1905 stream->upload_left = Curl_bufq_len(&stream->sendbuf);
1906 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id);
1911 struct h3_stream_ctx *stream = H3_STREAM_CTX(data);
1913 if(stream && !stream->closed) {