Repository: trafficserver Updated Branches: refs/heads/master 09acc0b81 -> 6a111c1e6
TS-3827: Cleanup comments related to HTTP/2 This closes #315 Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/16821eed Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/16821eed Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/16821eed Branch: refs/heads/master Commit: 16821eed48a3343cf522501f272950e30b07aa4a Parents: c498d7e Author: Masaori Koshiba <[email protected]> Authored: Tue Oct 20 16:56:41 2015 +0900 Committer: James Peach <[email protected]> Committed: Tue Oct 27 19:15:17 2015 -0700 ---------------------------------------------------------------------- proxy/http2/HTTP2.cc | 62 +------------------------------ proxy/http2/HTTP2.h | 49 ++++++++++++------------- proxy/http2/Http2ConnectionState.cc | 63 +++++++------------------------- 3 files changed, 39 insertions(+), 135 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/16821eed/proxy/http2/HTTP2.cc ---------------------------------------------------------------------- diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc index e5d3b94..82b1657 100644 --- a/proxy/http2/HTTP2.cc +++ b/proxy/http2/HTTP2.cc @@ -285,18 +285,6 @@ http2_write_ping(const uint8_t *opaque_data, IOVec iov) return true; } -// 6.8. GOAWAY -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |R| Last-Stream-ID (31) | -// +-+-------------------------------------------------------------+ -// | Error Code (32) | -// +---------------------------------------------------------------+ -// | Additional Debug Data (*) | -// +---------------------------------------------------------------+ - bool http2_write_goaway(const Http2Goaway &goaway, IOVec iov) { @@ -330,16 +318,6 @@ http2_parse_headers_parameter(IOVec iov, Http2HeadersParameter ¶ms) return true; } -// 6.3. PRIORITY -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |E| Stream Dependency (31) | -// +-+-------------+-----------------------------------------------+ -// | Weight (8) | -// +-+-------------+ - bool http2_parse_priority_parameter(IOVec iov, Http2Priority ¶ms) { @@ -354,14 +332,6 @@ http2_parse_priority_parameter(IOVec iov, Http2Priority ¶ms) return true; } -// 6.4. RST_STREAM -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Error Code (32) | -// +---------------------------------------------------------------+ - bool http2_parse_rst_stream(IOVec iov, Http2RstStream &rst_stream) { @@ -375,16 +345,6 @@ http2_parse_rst_stream(IOVec iov, Http2RstStream &rst_stream) return true; } -// 6.5.1. SETTINGS Format -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Identifier (16) | -// +-------------------------------+-------------------------------+ -// | Value (32) | -// +---------------------------------------------------------------+ - bool http2_parse_settings_parameter(IOVec iov, Http2SettingsParameter ¶m) { @@ -405,18 +365,6 @@ http2_parse_settings_parameter(IOVec iov, Http2SettingsParameter ¶m) return true; } -// 6.8. GOAWAY -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |R| Last-Stream-ID (31) | -// +-+-------------------------------------------------------------+ -// | Error Code (32) | -// +---------------------------------------------------------------+ -// | Additional Debug Data (*) | -// +---------------------------------------------------------------+ - bool http2_parse_goaway(IOVec iov, Http2Goaway &goaway) { @@ -432,14 +380,6 @@ http2_parse_goaway(IOVec iov, Http2Goaway &goaway) return true; } -// 6.9. WINDOW_UPDATE -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |R| Window Size Increment (31) | -// +-+-------------------------------------------------------------+ - bool http2_parse_window_update(IOVec iov, uint32_t &size) { @@ -506,7 +446,7 @@ convert_from_2_to_1_1_header(HTTPHdr *headers) return PARSE_ERROR; } - // 8.1.2.5 Combine Cookie headers + // Combine Cookie headers ([RFC 7540] 8.1.2.5.) field = headers->field_find(MIME_FIELD_COOKIE, MIME_LEN_COOKIE); if (field) { headers->field_combine_dups(field, true, ';'); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/16821eed/proxy/http2/HTTP2.h ---------------------------------------------------------------------- diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h index d0278d6..9120d7c 100644 --- a/proxy/http2/HTTP2.h +++ b/proxy/http2/HTTP2.h @@ -34,9 +34,8 @@ class HTTPHdr; typedef unsigned Http2StreamId; -// 6.9.2 Initial Flow Control Window Size - the flow control window can be come -// negative -// so we need to track it with a signed type. +// [RFC 7540] 6.9.2. Initial Flow Control Window Size +// the flow control window can be come negative so we need to track it with a signed type. typedef int32_t Http2WindowSize; extern const char *const HTTP2_CONNECTION_PREFACE; @@ -79,17 +78,17 @@ enum { #define HTTP2_SUM_THREAD_DYN_STAT(_s, _t, _v) RecIncrRawStat(http2_rsb, _t, (int)_s, _v); extern RecRawStatBlock *http2_rsb; // Container for statistics. -// 6.9.1 The Flow Control Window +// [RFC 7540] 6.9.1. The Flow Control Window static const Http2WindowSize HTTP2_MAX_WINDOW_SIZE = 0x7FFFFFFF; -// 5.4. Error Handling +// [RFC 7540] 5.4. Error Handling enum Http2ErrorClass { HTTP2_ERROR_CLASS_NONE, HTTP2_ERROR_CLASS_CONNECTION, HTTP2_ERROR_CLASS_STREAM, }; -// 7. Error Codes +// [RFC 7540] 7. Error Codes enum Http2ErrorCode { HTTP2_ERROR_NO_ERROR = 0, HTTP2_ERROR_PROTOCOL_ERROR = 1, @@ -109,7 +108,7 @@ enum Http2ErrorCode { HTTP2_ERROR_MAX, }; -// 5.1. Stream States +// [RFC 7540] 5.1. Stream States enum Http2StreamState { HTTP2_STREAM_STATE_IDLE, HTTP2_STREAM_STATE_RESERVED_LOCAL, @@ -135,7 +134,7 @@ enum Http2FrameType { HTTP2_FRAME_TYPE_MAX, }; -// 6.1 Data +// [RFC 7540] 6.1. Data enum Http2FrameFlagsData { HTTP2_FLAGS_DATA_END_STREAM = 0x01, HTTP2_FLAGS_DATA_PADDED = 0x08, @@ -143,7 +142,7 @@ enum Http2FrameFlagsData { HTTP2_FLAGS_DATA_MASK = 0x09, }; -// 6.2 Headers +// [RFC 7540] 6.2. Headers enum Http2FrameFlagsHeaders { HTTP2_FLAGS_HEADERS_END_STREAM = 0x01, HTTP2_FLAGS_HEADERS_END_HEADERS = 0x04, @@ -153,24 +152,24 @@ enum Http2FrameFlagsHeaders { HTTP2_FLAGS_HEADERS_MASK = 0x2D, }; -// 6.3 Priority +// [RFC 7540] 6.3. Priority enum Http2FrameFlagsPriority { HTTP2_FLAGS_PRIORITY_MASK = 0x00, }; -// 6.3 Rst Stream +// [RFC 7540] 6.4. Rst Stream enum Http2FrameFlagsRstStream { HTTP2_FLAGS_RST_STREAM_MASK = 0x00, }; -// 6.4 Settings +// [RFC 7540] 6.5. Settings enum Http2FrameFlagsSettings { HTTP2_FLAGS_SETTINGS_ACK = 0x01, HTTP2_FLAGS_SETTINGS_MASK = 0x01 }; -// 6.6 Push Promise +// [RFC 7540] 6.6. Push Promise enum Http2FrameFlagsPushPromise { HTTP2_FLAGS_PUSH_PROMISE_END_HEADERS = 0x04, HTTP2_FLAGS_PUSH_PROMISE_PADDED = 0x08, @@ -178,31 +177,31 @@ enum Http2FrameFlagsPushPromise { HTTP2_FLAGS_PUSH_PROMISE_MASK = 0x0C, }; -// 6.7 Ping +// [RFC 7540] 6.7. Ping enum Http2FrameFlagsPing { HTTP2_FLAGS_PING_ACK = 0x01, HTTP2_FLAGS_PING_MASK = 0x01 }; -// 6.8 Goaway +// [RFC 7540] 6.8. Goaway enum Http2FrameFlagsGoaway { HTTP2_FLAGS_GOAWAY_MASK = 0x00, }; -// 6.9 Window Update +// [RFC 7540] 6.9. Window Update enum Http2FrameFlagsWindowUpdate { HTTP2_FLAGS_WINDOW_UPDATE_MASK = 0x00, }; -// 6.10 Continuation +// [RFC 7540] 6.10. Continuation enum Http2FrameFlagsContinuation { HTTP2_FLAGS_CONTINUATION_END_HEADERS = 0x04, HTTP2_FLAGS_CONTINUATION_MASK = 0x04, }; -// 6.5.2 Defined SETTINGS Parameters +// [RFC 7540] 6.5.2. Defined SETTINGS Parameters enum Http2SettingsIdentifier { HTTP2_SETTINGS_HEADER_TABLE_SIZE = 1, HTTP2_SETTINGS_ENABLE_PUSH = 2, @@ -214,7 +213,7 @@ enum Http2SettingsIdentifier { HTTP2_SETTINGS_MAX }; -// 4.1. Frame Format +// [RFC 7540] 4.1. Frame Format struct Http2FrameHeader { uint32_t length; uint8_t type; @@ -222,7 +221,7 @@ struct Http2FrameHeader { Http2StreamId streamid; }; -// 5.4. Error Handling +// [RFC 7540] 5.4. Error Handling struct Http2Error { Http2Error(const Http2ErrorClass error_class = HTTP2_ERROR_CLASS_NONE, const Http2ErrorCode error_code = HTTP2_ERROR_NO_ERROR) { @@ -234,13 +233,13 @@ struct Http2Error { Http2ErrorCode code; }; -// 6.5.1. SETTINGS Format +// [RFC 7540] 6.5.1. SETTINGS Format struct Http2SettingsParameter { uint16_t id; uint32_t value; }; -// 6.3 PRIORITY +// [RFC 7540] 6.3 PRIORITY Format struct Http2Priority { Http2Priority() : stream_dependency(0), weight(15) {} @@ -248,7 +247,7 @@ struct Http2Priority { uint8_t weight; }; -// 6.2 HEADERS Format +// [RFC 7540] 6.2 HEADERS Format struct Http2HeadersParameter { Http2HeadersParameter() : pad_length(0) {} @@ -256,7 +255,7 @@ struct Http2HeadersParameter { Http2Priority priority; }; -// 6.8 GOAWAY Format +// [RFC 7540] 6.8 GOAWAY Format struct Http2Goaway { Http2Goaway() : last_streamid(0), error_code(0) {} @@ -270,7 +269,7 @@ struct Http2Goaway { // just complicates memory management. }; -// 6.4 RST_STREAM Format +// [RFC 7540] 6.4 RST_STREAM Format struct Http2RstStream { uint32_t error_code; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/16821eed/proxy/http2/Http2ConnectionState.cc ---------------------------------------------------------------------- diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index a0fff63..ce89046 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -165,9 +165,9 @@ rcv_data_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const Http2 * * NOTE: HEADERS Frame and CONTINUATION Frame * 1. A HEADERS frame with the END_STREAM flag set can be followed by - *CONTINUATION frames on the same stream. + * CONTINUATION frames on the same stream. * 2. A HEADERS frame without the END_HEADERS flag set MUST be followed by a - *CONTINUATION frame + * CONTINUATION frame */ static Http2Error rcv_headers_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const Http2Frame &frame) @@ -360,7 +360,7 @@ rcv_settings_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const H DebugSsn(&cs, "http2_cs", "[%" PRId64 "] Received SETTINGS frame.", cs.connection_id()); - // 6.5 The stream identifier for a SETTINGS frame MUST be zero. + // [RFC 7540] 6.5. The stream identifier for a SETTINGS frame MUST be zero. // If an endpoint receives a SETTINGS frame whose stream identifier field is // anything other than 0x0, the endpoint MUST respond with a connection // error (Section 5.4.1) of type PROTOCOL_ERROR. @@ -368,7 +368,7 @@ rcv_settings_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const H return Http2Error(HTTP2_ERROR_CLASS_CONNECTION, HTTP2_ERROR_PROTOCOL_ERROR); } - // 6.5 Receipt of a SETTINGS frame with the ACK flag set and a + // [RFC 7540] 6.5. Receipt of a SETTINGS frame with the ACK flag set and a // length field value other than 0 MUST be treated as a connection // error of type FRAME_SIZE_ERROR. if (frame.header().flags & HTTP2_FLAGS_SETTINGS_ACK) { @@ -403,7 +403,7 @@ rcv_settings_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const H DebugSsn(&cs, "http2_cs", "[%" PRId64 "] setting param=%d value=%u", cs.connection_id(), param.id, param.value); - // 6.9.2. When the value of SETTINGS_INITIAL_WINDOW_SIZE + // [RFC 7540] 6.9.2. When the value of SETTINGS_INITIAL_WINDOW_SIZE // changes, a receiver MUST adjust the size of all stream flow control // windows that it maintains by the difference between the new value and // the old value. @@ -414,9 +414,8 @@ rcv_settings_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const H cstate.client_settings.set((Http2SettingsIdentifier)param.id, param.value); } - // 6.5 Once all values have been applied, the recipient MUST immediately emit - // a - // SETTINGS frame with the ACK flag set. + // [RFC 7540] 6.5. Once all values have been applied, the recipient MUST + // immediately emit a SETTINGS frame with the ACK flag set. Http2Frame ackFrame(HTTP2_FRAME_TYPE_SETTINGS, 0, HTTP2_FLAGS_SETTINGS_ACK); cstate.ua_session->handleEvent(HTTP2_SESSION_EVENT_XMIT, &ackFrame); @@ -428,12 +427,11 @@ rcv_push_promise_frame(Http2ClientSession &cs, Http2ConnectionState & /*cstate*/ { DebugSsn(&cs, "http2_cs", "[%" PRId64 "] received PUSH_PROMISE frame", cs.connection_id()); - // 8.2. A client cannot push. Thus, servers MUST treat the receipt of a + // [RFC 7540] 8.2. A client cannot push. Thus, servers MUST treat the receipt of a // PUSH_PROMISE frame as a connection error of type PROTOCOL_ERROR. return Http2Error(HTTP2_ERROR_CLASS_CONNECTION, HTTP2_ERROR_PROTOCOL_ERROR); } -// 6.7. PING static Http2Error rcv_ping_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const Http2Frame &frame) { @@ -442,8 +440,7 @@ rcv_ping_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, const Http2 DebugSsn(&cs, "http2_cs", "[%" PRId64 "] Received PING frame.", cs.connection_id()); // If a PING frame is received with a stream identifier field value other - // than - // 0x0, the recipient MUST respond with a connection error of type + // than 0x0, the recipient MUST respond with a connection error of type // PROTOCOL_ERROR. if (frame.header().streamid != 0x0) { return Http2Error(HTTP2_ERROR_CLASS_CONNECTION, HTTP2_ERROR_PROTOCOL_ERROR); @@ -607,8 +604,7 @@ rcv_continuation_frame(Http2ClientSession &cs, Http2ConnectionState &cstate, con // CONTINUATION frames MUST be associated with a stream. If a // CONTINUATION frame is received whose stream identifier field is 0x0, // the recipient MUST respond with a connection error ([RFC 7540] Section - // 5.4.1) of - // type PROTOCOL_ERROR. + // 5.4.1) of type PROTOCOL_ERROR. Http2Stream *stream = cstate.find_stream(stream_id); if (stream == NULL) { if (stream_id <= cstate.get_latest_stream_id()) { @@ -691,7 +687,7 @@ Http2ConnectionState::main_event_handler(int event, void *edata) ink_assert(this->ua_session == NULL); this->ua_session = (Http2ClientSession *)edata; - // 3.5 HTTP/2 Connection Preface. Upon establishment of a TCP connection and + // [RFC 7540] 3.5. HTTP/2 Connection Preface. Upon establishment of a TCP connection and // determination that HTTP/2 will be used by both peers, each endpoint MUST // send a connection preface as a final confirmation ... The server // connection @@ -724,9 +720,8 @@ Http2ConnectionState::main_event_handler(int event, void *edata) Http2StreamId last_streamid = frame->header().streamid; Http2Error error; - // 5.5 Extending HTTP/2 - // Implementations MUST discard frames that have unknown or unsupported - // types. + // [RFC 7540] 5.5. Extending HTTP/2 + // Implementations MUST discard frames that have unknown or unsupported types. if (frame->header().type >= HTTP2_FRAME_TYPE_MAX) { DebugSsn(this->ua_session, "http2_cs", "[%" PRId64 "] Discard a frame which has unknown type, type=%x", this->ua_session->connection_id(), frame->header().type); @@ -946,8 +941,7 @@ Http2ConnectionState::send_data_frame(FetchSM *fetch_sm) // Delete a stream immediately // TODO its should not be deleted for a several time to handling // RST_STREAM and WINDOW_UPDATE. - // See 'closed' state written at - // https://tools.ietf.org/html/draft-ietf-httpbis-http2-16#section-5.1 + // See 'closed' state written at [RFC 7540] 5.1. this->delete_stream(stream); break; } @@ -1164,35 +1158,6 @@ Http2Stream::set_body_to_fetcher(const void *data, size_t len) _fetch_sm->ext_write_data(data, len); } -/* - * 5.1. Stream States - * - * +--------+ - * PP | | PP - * ,--------| idle |--------. - * / | | \ - * v +--------+ v - * +----------+ | +----------+ - * | | | H | | - * ,---| reserved | | | reserved |---. - * | | (local) | v | (remote) | | - * | +----------+ +--------+ +----------+ | - * | | ES | | ES | | - * | | H ,-------| open |-------. | H | - * | | / | | \ | | - * | v v +--------+ v v | - * | +----------+ | +----------+ | - * | | half | | | half | | - * | | closed | | R | closed | | - * | | (remote) | | | (local) | | - * | +----------+ | +----------+ | - * | | v | | - * | | ES / R +--------+ ES / R | | - * | `----------->| |<-----------' | - * | R | closed | R | - * `-------------------->| |<--------------------' - * +--------+ - */ bool Http2Stream::change_state(uint8_t type, uint8_t flags) {
