MCPcopy Create free account
hub / github.com/apache/trafficserver / change_state

Method change_state

src/proxy/http2/Http2Stream.cc:402–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402bool
403Http2Stream::change_state(uint8_t type, uint8_t flags)
404{
405 auto const initial_state = _state;
406 switch (_state) {
407 case Http2StreamState::HTTP2_STREAM_STATE_IDLE:
408 if (type == HTTP2_FRAME_TYPE_HEADERS) {
409 if (receive_end_stream) {
410 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE;
411 } else if (send_end_stream) {
412 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_LOCAL;
413 } else {
414 _state = Http2StreamState::HTTP2_STREAM_STATE_OPEN;
415 }
416 } else if (type == HTTP2_FRAME_TYPE_CONTINUATION) {
417 if (receive_end_stream) {
418 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE;
419 } else if (send_end_stream) {
420 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_LOCAL;
421 } else {
422 _state = Http2StreamState::HTTP2_STREAM_STATE_OPEN;
423 }
424 } else if (type == HTTP2_FRAME_TYPE_PUSH_PROMISE) {
425 _state = Http2StreamState::HTTP2_STREAM_STATE_RESERVED_LOCAL;
426 } else if (type == HTTP2_FRAME_TYPE_RST_STREAM) {
427 _state = Http2StreamState::HTTP2_STREAM_STATE_CLOSED;
428 } else {
429 return false;
430 }
431 break;
432
433 case Http2StreamState::HTTP2_STREAM_STATE_OPEN:
434 if (type == HTTP2_FRAME_TYPE_RST_STREAM) {
435 _state = Http2StreamState::HTTP2_STREAM_STATE_CLOSED;
436 } else if (type == HTTP2_FRAME_TYPE_HEADERS || type == HTTP2_FRAME_TYPE_DATA) {
437 if (receive_end_stream) {
438 if (send_end_stream) {
439 _state = Http2StreamState::HTTP2_STREAM_STATE_CLOSED;
440 } else {
441 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE;
442 }
443 } else if (send_end_stream) {
444 if (receive_end_stream) {
445 _state = Http2StreamState::HTTP2_STREAM_STATE_CLOSED;
446 } else {
447 _state = Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_LOCAL;
448 }
449 } else {
450 // Do not change state
451 }
452 } else {
453 // A stream in the "open" state may be used by both peers to send frames of any type.
454 return true;
455 }
456 break;
457
458 case Http2StreamState::HTTP2_STREAM_STATE_RESERVED_LOCAL:
459 if (type == HTTP2_FRAME_TYPE_HEADERS) {

Callers 8

rcv_data_frameMethod · 0.80
rcv_headers_frameMethod · 0.80
rcv_rst_stream_frameMethod · 0.80
send_a_data_frameMethod · 0.80
send_headers_frameMethod · 0.80
send_rst_stream_frameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected