Skip to content

Commit

Permalink
Slightly improved ASCII art diagram.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 18, 2024
1 parent bf18c8b commit fb07f77
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions lib/protocol/http2/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module Protocol
module HTTP2
# A single HTTP 2.0 connection can multiplex multiple streams in parallel:
# A single HTTP/2 connection can multiplex multiple streams in parallel:
# multiple requests and responses can be in flight simultaneously and stream
# data can be interleaved and prioritized.
#
Expand All @@ -18,42 +18,44 @@ module HTTP2
# diagram below) and provide your application logic to handle request
# and response processing.
#
# +--------+
# send PP | | recv PP
# ,--------| idle |--------.
# / | | \
# v +--------+ v
# +----------+ | +----------+
# | | | send H / | |
# ,------| reserved | | recv H | reserved |------.
# | | (local) | | | (remote) | |
# | +----------+ v +----------+ |
# | | +--------+ | |
# | | recv ES | | send ES | |
# | send H | ,-------| open |-------. | recv H |
# | | / | | \ | |
# | v v +--------+ v v |
# | +----------+ | +----------+ |
# | | half | | | half | |
# | | closed | | send R / | closed | |
# | | (remote) | | recv R | (local) | |
# | +----------+ | +----------+ |
# | | | | |
# | | send ES / | recv ES / | |
# | | send R / v send R / | |
# | | recv R +--------+ recv R | |
# | send R / `----------->| |<-----------' send R / |
# | recv R | closed | recv R |
# `----------------------->| |<----------------------'
# +--------+
#
# send: endpoint sends this frame
# recv: endpoint receives this frame
#
# H: HEADERS frame (with implied CONTINUATIONs)
# PP: PUSH_PROMISE frame (with implied CONTINUATIONs)
# ES: END_STREAM flag
# R: RST_STREAM frame
# ```
# ┌────────┐
# send PP │ │ recv PP
# ┌──────────┤ idle ├──────────┐
# │ │ │ │
# ▼ └───┬────┘ ▼
# ┌──────────┐ │ ┌──────────┐
# │ │ │ send H / │ │
# ┌──────┼ reserved │ │ recv H │ reserved ├──────┐
# │ │ (local) │ │ │ (remote) │ │
# │ └───┬──────┘ ▼ └──────┬───┘ │
# │ │ ┌────────┐ │ │
# │ │ recv ES │ │ send ES │ │
# │ send H │ ┌─────────┤ open ├─────────┐ │ recv H │
# │ │ │ │ │ │ │ │
# │ ▼ ▼ └───┬────┘ ▼ ▼ │
# │ ┌──────────┐ │ ┌──────────┐ │
# │ │ half │ │ │ half │ │
# │ │ closed │ │ send R / │ closed │ │
# │ │ (remote) │ │ recv R │ (local) │ │
# │ └────┬─────┘ │ └─────┬────┘ │
# │ │ │ │ │
# │ │ send ES / │ recv ES / │ │
# │ │ send R / ▼ send R / │ │
# │ │ recv R ┌────────┐ recv R │ │
# │ send R / └───────────►│ │◄───────────┘ send R / │
# │ recv R │ closed │ recv R │
# └───────────────────────►│ │◄───────────────────────┘
# └────────┘
# ```
#
# - `send`: endpoint sends this frame
# - `recv`: endpoint receives this frame
#
# - H: HEADERS frame (with implied CONTINUATIONs)
# - PP: PUSH_PROMISE frame (with implied CONTINUATIONs)
# - ES: END_STREAM flag
# - R: RST_STREAM frame
#
# State transition methods use a trailing "!".
class Stream
Expand Down

0 comments on commit fb07f77

Please sign in to comment.