From 62acceb2fda95d23ae8081ac3d22e7b49e8ee099 Mon Sep 17 00:00:00 2001 From: bnc Date: Wed, 12 Nov 2014 21:41:39 -0800 Subject: [PATCH] Add HTTP/2 error code from latest draft. Add HTTP_1_1_REQUIRED error code for RST_STREAM and GOAWAY frames that was introduced in draft-15. Also add INADEQUATE_SECURTY error code wherever it had been forgotten. This lands server change 79690279 by bnc in spdy_framer.cc and spdy_protocol.{h,cc}. BUG=431306 Review URL: https://codereview.chromium.org/700583005 Cr-Commit-Position: refs/heads/master@{#303993} --- net/spdy/spdy_framer.cc | 4 ++++ net/spdy/spdy_protocol.cc | 17 +++++++++++++++-- net/spdy/spdy_protocol.h | 7 +++++-- net/spdy/spdy_session.cc | 4 ++++ net/spdy/spdy_session.h | 6 ++++-- net/spdy/spdy_session_unittest.cc | 4 ++++ 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 800b7704a918..c08b59763323 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -480,6 +480,10 @@ const char* SpdyFramer::StatusCodeToString(int status_code) { return "CONNECT_ERROR"; case RST_STREAM_ENHANCE_YOUR_CALM: return "ENHANCE_YOUR_CALM"; + case RST_STREAM_INADEQUATE_SECURITY: + return "INADEQUATE_SECURITY"; + case RST_STREAM_HTTP_1_1_REQUIRED: + return "HTTP_1_1_REQUIRED"; } return "UNKNOWN_STATUS"; } diff --git a/net/spdy/spdy_protocol.cc b/net/spdy/spdy_protocol.cc index d300a15fca31..bf33d43944ab 100644 --- a/net/spdy/spdy_protocol.cc +++ b/net/spdy/spdy_protocol.cc @@ -372,9 +372,9 @@ bool SpdyConstants::IsValidRstStreamStatus(SpdyMajorVersion version, } */ - // ENHANCE_YOUR_CALM is the last valid status code. + // HTTP_1_1_REQUIRED is the last valid status code. if (rst_stream_status_field > - SerializeRstStreamStatus(version, RST_STREAM_ENHANCE_YOUR_CALM)) { + SerializeRstStreamStatus(version, RST_STREAM_HTTP_1_1_REQUIRED)) { return false; } @@ -436,6 +436,10 @@ SpdyRstStreamStatus SpdyConstants::ParseRstStreamStatus( return RST_STREAM_CONNECT_ERROR; case 11: return RST_STREAM_ENHANCE_YOUR_CALM; + case 12: + return RST_STREAM_INADEQUATE_SECURITY; + case 13: + return RST_STREAM_HTTP_1_1_REQUIRED; } break; } @@ -499,6 +503,10 @@ int SpdyConstants::SerializeRstStreamStatus( return 10; case RST_STREAM_ENHANCE_YOUR_CALM: return 11; + case RST_STREAM_INADEQUATE_SECURITY: + return 12; + case RST_STREAM_HTTP_1_1_REQUIRED: + return 13; default: LOG(DFATAL) << "Unhandled RST_STREAM status " << rst_stream_status; @@ -589,6 +597,8 @@ SpdyGoAwayStatus SpdyConstants::ParseGoAwayStatus(SpdyMajorVersion version, return GOAWAY_ENHANCE_YOUR_CALM; case 12: return GOAWAY_INADEQUATE_SECURITY; + case 13: + return GOAWAY_HTTP_1_1_REQUIRED; } break; } @@ -666,6 +676,7 @@ int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version, case GOAWAY_CONNECT_ERROR: case GOAWAY_ENHANCE_YOUR_CALM: case GOAWAY_INADEQUATE_SECURITY: + case GOAWAY_HTTP_1_1_REQUIRED: return 1; // PROTOCOL_ERROR. default: LOG(DFATAL) << "Serializing unhandled GOAWAY status " << status; @@ -700,6 +711,8 @@ int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version, return 11; case GOAWAY_INADEQUATE_SECURITY: return 12; + case GOAWAY_HTTP_1_1_REQUIRED: + return 13; default: LOG(DFATAL) << "Serializing unhandled GOAWAY status " << status; return -1; diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h index b3f71d4454f1..b02c44f2975b 100644 --- a/net/spdy/spdy_protocol.h +++ b/net/spdy/spdy_protocol.h @@ -397,7 +397,9 @@ enum SpdyRstStreamStatus { RST_STREAM_SETTINGS_TIMEOUT = 12, RST_STREAM_CONNECT_ERROR = 13, RST_STREAM_ENHANCE_YOUR_CALM = 14, - RST_STREAM_NUM_STATUS_CODES = 15 + RST_STREAM_INADEQUATE_SECURITY = 15, + RST_STREAM_HTTP_1_1_REQUIRED = 16, + RST_STREAM_NUM_STATUS_CODES = 17 }; // Status codes for GOAWAY frames. @@ -415,7 +417,8 @@ enum SpdyGoAwayStatus { GOAWAY_COMPRESSION_ERROR = 9, GOAWAY_CONNECT_ERROR = 10, GOAWAY_ENHANCE_YOUR_CALM = 11, - GOAWAY_INADEQUATE_SECURITY = 12 + GOAWAY_INADEQUATE_SECURITY = 12, + GOAWAY_HTTP_1_1_REQUIRED = 13 }; // A SPDY priority is a number between 0 and 7 (inclusive). diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 5430e27ff478..c324a09348d0 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -398,6 +398,10 @@ SpdyProtocolErrorDetails MapRstStreamStatusToProtocolError( return STATUS_CODE_CONNECT_ERROR; case RST_STREAM_ENHANCE_YOUR_CALM: return STATUS_CODE_ENHANCE_YOUR_CALM; + case RST_STREAM_INADEQUATE_SECURITY: + return STATUS_CODE_INADEQUATE_SECURITY; + case RST_STREAM_HTTP_1_1_REQUIRED: + return STATUS_CODE_HTTP_1_1_REQUIRED; default: NOTREACHED(); return static_cast(-1); diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index bf64cec98bc5..862918b00b49 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -105,6 +105,8 @@ enum SpdyProtocolErrorDetails { STATUS_CODE_SETTINGS_TIMEOUT = 32, STATUS_CODE_CONNECT_ERROR = 33, STATUS_CODE_ENHANCE_YOUR_CALM = 34, + STATUS_CODE_INADEQUATE_SECURITY = 35, + STATUS_CODE_HTTP_1_1_REQUIRED = 36, // SpdySession errors PROTOCOL_ERROR_UNEXPECTED_PING = 22, @@ -116,7 +118,7 @@ enum SpdyProtocolErrorDetails { PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION = 28, // Next free value. - NUM_SPDY_PROTOCOL_ERROR_DETAILS = 35, + NUM_SPDY_PROTOCOL_ERROR_DETAILS = 37, }; SpdyProtocolErrorDetails NET_EXPORT_PRIVATE MapFramerErrorToProtocolError(SpdyFramer::SpdyError error); @@ -129,7 +131,7 @@ SpdyGoAwayStatus NET_EXPORT_PRIVATE MapNetErrorToGoAwayStatus(Error err); // to be updated with new values, as do the mapping functions above. COMPILE_ASSERT(12 == SpdyFramer::LAST_ERROR, SpdyProtocolErrorDetails_SpdyErrors_mismatch); -COMPILE_ASSERT(15 == RST_STREAM_NUM_STATUS_CODES, +COMPILE_ASSERT(17 == RST_STREAM_NUM_STATUS_CODES, SpdyProtocolErrorDetails_RstStreamStatus_mismatch); // Splits pushed |headers| into request and response parts. Request headers are diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index c6447bf05e9b..256e1a7efd19 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -5019,6 +5019,10 @@ TEST(MapRstStreamStatusToProtocolError, MapsValues) { MapRstStreamStatusToProtocolError(RST_STREAM_FRAME_SIZE_ERROR)); CHECK_EQ(STATUS_CODE_ENHANCE_YOUR_CALM, MapRstStreamStatusToProtocolError(RST_STREAM_ENHANCE_YOUR_CALM)); + CHECK_EQ(STATUS_CODE_INADEQUATE_SECURITY, + MapRstStreamStatusToProtocolError(RST_STREAM_INADEQUATE_SECURITY)); + CHECK_EQ(STATUS_CODE_HTTP_1_1_REQUIRED, + MapRstStreamStatusToProtocolError(RST_STREAM_HTTP_1_1_REQUIRED)); } TEST(MapNetErrorToGoAwayStatus, MapsValue) { -- 2.11.4.GIT