MCPcopy Create free account
hub / github.com/apache/httpd / h2_stream_recv_frame

Function h2_stream_recv_frame

modules/http2/h2_stream.c:475–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475apr_status_t h2_stream_recv_frame(h2_stream *stream, int ftype, int flags, size_t frame_len)
476{
477 apr_status_t status = APR_SUCCESS;
478 int new_state, eos = 0;
479
480 H2_STRM_ASSERT_MAGIC(stream, H2_STRM_MAGIC_OK);
481 new_state = on_frame_recv(stream->state, ftype);
482 if (new_state < 0) {
483 ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c1,
484 H2_STRM_MSG(stream, "invalid frame %d recv"), ftype);
485 AP_DEBUG_ASSERT(new_state > S_XXX);
486 return transit(stream, new_state);
487 }
488
489 switch (ftype) {
490 case NGHTTP2_DATA:
491 eos = (flags & NGHTTP2_FLAG_END_STREAM);
492 break;
493
494 case NGHTTP2_HEADERS:
495 eos = (flags & NGHTTP2_FLAG_END_STREAM);
496 if (h2_stream_is_at_or_past(stream, H2_SS_OPEN)) {
497 /* trailer HEADER */
498 if (!eos) {
499 h2_stream_rst(stream, H2_ERR_PROTOCOL_ERROR);
500 }
501 stream->in_trailer_octets += frame_len;
502 }
503 else {
504 /* request HEADER */
505 ap_assert(stream->request == NULL);
506 if (stream->rtmp == NULL) {
507 /* This can only happen, if the stream has received no header
508 * name/value pairs at all. The latest nghttp2 version have become
509 * pretty good at detecting this early. In any case, we have
510 * to abort the connection here, since this is clearly a protocol error */
511 return APR_EINVAL;
512 }
513 status = h2_stream_end_headers(stream, eos, frame_len);
514 if (status != APR_SUCCESS) goto leave;
515 }
516 break;
517
518 default:
519 break;
520 }
521 status = transit(stream, new_state);
522 if (status == APR_SUCCESS && eos) {
523 status = transit(stream, on_event(stream, H2_SEV_CLOSED_R));
524 }
525leave:
526 return status;
527}
528
529apr_status_t h2_stream_recv_DATA(h2_stream *stream, uint8_t flags,
530 const uint8_t *data, size_t len)

Callers 2

on_frame_recv_cbFunction · 0.85

Calls 6

h2_stream_is_at_or_pastFunction · 0.85
h2_stream_rstFunction · 0.85
h2_stream_end_headersFunction · 0.85
on_frame_recvFunction · 0.70
transitFunction · 0.70
on_eventFunction · 0.70

Tested by

no test coverage detected