Lines Matching refs:stream
77 static int check_pseudo_header(nghttp2_stream *stream, const nghttp2_hd_nv *nv,
79 if ((stream->http_flags & flag) || nv->value->len == 0) {
82 stream->http_flags = stream->http_flags | flag;
86 static int expect_response_body(nghttp2_stream *stream) {
87 return (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_HEAD) == 0 &&
88 stream->status_code / 100 != 1 && stream->status_code != 304 &&
89 stream->status_code != 204;
97 static int check_path(nghttp2_stream *stream) {
98 return (stream->http_flags & NGHTTP2_HTTP_FLAG_SCHEME_HTTP) == 0 ||
99 ((stream->http_flags & NGHTTP2_HTTP_FLAG_PATH_REGULAR) ||
100 ((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_OPTIONS) &&
101 (stream->http_flags & NGHTTP2_HTTP_FLAG_PATH_ASTERISK)));
104 static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
110 (stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) {
117 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__AUTHORITY)) {
122 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__METHOD)) {
128 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_HEAD;
135 if (stream->stream_id % 2 == 0) {
139 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_CONNECT;
144 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_OPTIONS;
152 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PATH)) {
156 stream->http_flags |= NGHTTP2_HTTP_FLAG_PATH_REGULAR;
158 stream->http_flags |= NGHTTP2_HTTP_FLAG_PATH_ASTERISK;
162 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__SCHEME)) {
167 stream->http_flags |= NGHTTP2_HTTP_FLAG_SCHEME_HTTP;
175 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PROTOCOL)) {
180 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG_HOST)) {
185 if (stream->content_length != -1) {
188 stream->content_length = parse_uint(nv->value->base, nv->value->len);
189 if (stream->content_length == -1) {
209 (stream->stream_id & 1) &&
210 (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) &&
211 !(stream->http_flags & NGHTTP2_HTTP_FLAG_BAD_PRIORITY)) {
212 nghttp2_extpri_from_uint8(&extpri, stream->http_extpri);
215 stream->http_extpri = nghttp2_extpri_to_uint8(&extpri);
216 stream->http_flags |= NGHTTP2_HTTP_FLAG_PRIORITY;
218 stream->http_flags &= (uint32_t)~NGHTTP2_HTTP_FLAG_PRIORITY;
219 stream->http_flags |= NGHTTP2_HTTP_FLAG_BAD_PRIORITY;
230 stream->http_flags |= NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED;
236 static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
240 (stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) {
247 if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__STATUS)) {
253 stream->status_code = (int16_t)parse_uint(nv->value->base, nv->value->len);
254 if (stream->status_code == -1 || stream->status_code == 101) {
260 if (stream->status_code == 204) {
264 if (stream->content_length != -1) {
271 stream->content_length = 0;
274 if (stream->status_code / 100 == 1) {
278 if (stream->status_code / 100 == 2 &&
279 (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT)) {
282 if (stream->content_length != -1) {
285 stream->content_length = parse_uint(nv->value->base, nv->value->len);
286 if (stream->content_length == -1) {
310 stream->http_flags |= NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED;
350 int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
358 headers floating around and if we kill the stream because of
377 stream->http_flags |= NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED;
393 stream->flags &
407 if ((stream->flags &
415 if (stream->flags &
431 stream->http_flags |= NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED;
436 return http_request_on_header(stream, nv, trailer,
441 return http_response_on_header(stream, nv, trailer);
444 int nghttp2_http_on_request_headers(nghttp2_stream *stream,
446 if (!(stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
447 (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT)) {
448 if ((stream->http_flags &
450 (stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0) {
453 stream->content_length = -1;
455 if ((stream->http_flags & NGHTTP2_HTTP_FLAG_REQ_HEADERS) !=
457 (stream->http_flags &
461 if ((stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
462 ((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) == 0 ||
463 (stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0)) {
466 if (!check_path(stream)) {
474 stream->http_flags &= NGHTTP2_HTTP_FLAG_METH_ALL;
475 stream->content_length = -1;
481 int nghttp2_http_on_response_headers(nghttp2_stream *stream) {
482 if ((stream->http_flags & NGHTTP2_HTTP_FLAG__STATUS) == 0) {
486 if (stream->status_code / 100 == 1) {
488 stream->http_flags = (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_ALL) |
490 stream->content_length = -1;
491 stream->status_code = -1;
495 stream->http_flags =
496 stream->http_flags & (uint32_t)~NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE;
498 if (!expect_response_body(stream)) {
499 stream->content_length = 0;
500 } else if (stream->http_flags & (NGHTTP2_HTTP_FLAG_METH_CONNECT |
502 stream->content_length = -1;
508 int nghttp2_http_on_trailer_headers(nghttp2_stream *stream,
510 (void)stream;
519 int nghttp2_http_on_remote_end_stream(nghttp2_stream *stream) {
520 if (stream->http_flags & NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE) {
524 if (stream->content_length != -1 &&
525 stream->content_length != stream->recv_content_length) {
532 int nghttp2_http_on_data_chunk(nghttp2_stream *stream, size_t n) {
533 stream->recv_content_length += (int64_t)n;
535 if ((stream->http_flags & NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE) ||
536 (stream->content_length != -1 &&
537 stream->recv_content_length > stream->content_length)) {
544 void nghttp2_http_record_request_method(nghttp2_stream *stream,
571 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_CONNECT;
575 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_HEAD;