OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 case SPDY_UNEXPECTED_FRAME: | 531 case SPDY_UNEXPECTED_FRAME: |
532 return "UNEXPECTED_FRAME"; | 532 return "UNEXPECTED_FRAME"; |
533 case SPDY_INTERNAL_FRAMER_ERROR: | 533 case SPDY_INTERNAL_FRAMER_ERROR: |
534 return "SPDY_INTERNAL_FRAMER_ERROR"; | 534 return "SPDY_INTERNAL_FRAMER_ERROR"; |
535 } | 535 } |
536 return "UNKNOWN_ERROR"; | 536 return "UNKNOWN_ERROR"; |
537 } | 537 } |
538 | 538 |
539 const char* SpdyFramer::StatusCodeToString(int status_code) { | 539 const char* SpdyFramer::StatusCodeToString(int status_code) { |
540 switch (status_code) { | 540 switch (status_code) { |
541 case RST_STREAM_INVALID: | 541 case RST_STREAM_NO_ERROR: |
542 return "INVALID"; | 542 return "NO_ERROR"; |
543 case RST_STREAM_PROTOCOL_ERROR: | 543 case RST_STREAM_PROTOCOL_ERROR: |
544 return "PROTOCOL_ERROR"; | 544 return "PROTOCOL_ERROR"; |
545 case RST_STREAM_INVALID_STREAM: | 545 case RST_STREAM_INVALID_STREAM: |
546 return "INVALID_STREAM"; | 546 return "INVALID_STREAM"; |
547 case RST_STREAM_REFUSED_STREAM: | 547 case RST_STREAM_REFUSED_STREAM: |
548 return "REFUSED_STREAM"; | 548 return "REFUSED_STREAM"; |
549 case RST_STREAM_UNSUPPORTED_VERSION: | 549 case RST_STREAM_UNSUPPORTED_VERSION: |
550 return "UNSUPPORTED_VERSION"; | 550 return "UNSUPPORTED_VERSION"; |
551 case RST_STREAM_CANCEL: | 551 case RST_STREAM_CANCEL: |
552 return "CANCEL"; | 552 return "CANCEL"; |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 if (current_frame_buffer_.len() == header_size) { | 2100 if (current_frame_buffer_.len() == header_size) { |
2101 // Parse out the last good stream id. | 2101 // Parse out the last good stream id. |
2102 SpdyFrameReader reader(current_frame_buffer_.data(), | 2102 SpdyFrameReader reader(current_frame_buffer_.data(), |
2103 current_frame_buffer_.len()); | 2103 current_frame_buffer_.len()); |
2104 reader.Seek(GetFrameHeaderSize()); // Seek past frame header. | 2104 reader.Seek(GetFrameHeaderSize()); // Seek past frame header. |
2105 if (protocol_version_ == SPDY3) { | 2105 if (protocol_version_ == SPDY3) { |
2106 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); | 2106 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); |
2107 DCHECK(successful_read); | 2107 DCHECK(successful_read); |
2108 } | 2108 } |
2109 | 2109 |
2110 SpdyRstStreamStatus status = RST_STREAM_INVALID; | 2110 SpdyRstStreamStatus status = RST_STREAM_NO_ERROR; |
2111 uint32_t status_raw = status; | 2111 uint32_t status_raw = status; |
2112 bool successful_read = reader.ReadUInt32(&status_raw); | 2112 bool successful_read = reader.ReadUInt32(&status_raw); |
2113 DCHECK(successful_read); | 2113 DCHECK(successful_read); |
2114 if (SpdyConstants::IsValidRstStreamStatus(protocol_version_, | 2114 if (SpdyConstants::IsValidRstStreamStatus(protocol_version_, |
2115 status_raw)) { | 2115 status_raw)) { |
2116 status = | 2116 status = |
2117 SpdyConstants::ParseRstStreamStatus(protocol_version_, status_raw); | 2117 SpdyConstants::ParseRstStreamStatus(protocol_version_, status_raw); |
2118 } else { | 2118 } else { |
2119 if (protocol_version_ == HTTP2) { | 2119 if (protocol_version_ == HTTP2) { |
2120 // Treat unrecognized status codes as INTERNAL_ERROR as | 2120 // Treat unrecognized status codes as INTERNAL_ERROR as |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 #else | 3399 #else |
3400 WriteHeaderBlockToZ(&frame.header_block(), compressor); | 3400 WriteHeaderBlockToZ(&frame.header_block(), compressor); |
3401 #endif // defined(USE_SYSTEM_ZLIB) | 3401 #endif // defined(USE_SYSTEM_ZLIB) |
3402 | 3402 |
3403 int compressed_size = compressed_max_size - compressor->avail_out; | 3403 int compressed_size = compressed_max_size - compressor->avail_out; |
3404 builder->Seek(compressed_size); | 3404 builder->Seek(compressed_size); |
3405 builder->RewriteLength(*this); | 3405 builder->RewriteLength(*this); |
3406 } | 3406 } |
3407 | 3407 |
3408 } // namespace net | 3408 } // namespace net |
OLD | NEW |