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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 return "UNKNOWN_ERROR"; | 411 return "UNKNOWN_ERROR"; |
412 } | 412 } |
413 | 413 |
414 const char* SpdyFramer::StatusCodeToString(int status_code) { | 414 const char* SpdyFramer::StatusCodeToString(int status_code) { |
415 switch (status_code) { | 415 switch (status_code) { |
416 case RST_STREAM_NO_ERROR: | 416 case RST_STREAM_NO_ERROR: |
417 return "NO_ERROR"; | 417 return "NO_ERROR"; |
418 case RST_STREAM_PROTOCOL_ERROR: | 418 case RST_STREAM_PROTOCOL_ERROR: |
419 return "PROTOCOL_ERROR"; | 419 return "PROTOCOL_ERROR"; |
420 case RST_STREAM_INVALID_STREAM: | |
421 return "INVALID_STREAM"; | |
422 case RST_STREAM_REFUSED_STREAM: | |
423 return "REFUSED_STREAM"; | |
424 case RST_STREAM_UNSUPPORTED_VERSION: | |
425 return "UNSUPPORTED_VERSION"; | |
426 case RST_STREAM_CANCEL: | |
427 return "CANCEL"; | |
428 case RST_STREAM_INTERNAL_ERROR: | 420 case RST_STREAM_INTERNAL_ERROR: |
429 return "INTERNAL_ERROR"; | 421 return "INTERNAL_ERROR"; |
430 case RST_STREAM_FLOW_CONTROL_ERROR: | 422 case RST_STREAM_FLOW_CONTROL_ERROR: |
431 return "FLOW_CONTROL_ERROR"; | 423 return "FLOW_CONTROL_ERROR"; |
432 case RST_STREAM_STREAM_IN_USE: | 424 case RST_STREAM_SETTINGS_TIMEOUT: |
433 return "STREAM_IN_USE"; | 425 return "SETTINGS_TIMEOUT"; |
434 case RST_STREAM_STREAM_ALREADY_CLOSED: | 426 case RST_STREAM_STREAM_CLOSED: |
435 return "STREAM_ALREADY_CLOSED"; | 427 return "STREAM_CLOSED"; |
436 case RST_STREAM_FRAME_TOO_LARGE: | 428 case RST_STREAM_FRAME_SIZE_ERROR: |
437 return "FRAME_TOO_LARGE"; | 429 return "FRAME_SIZE_ERROR"; |
| 430 case RST_STREAM_REFUSED_STREAM: |
| 431 return "REFUSED_STREAM"; |
| 432 case RST_STREAM_CANCEL: |
| 433 return "CANCEL"; |
| 434 case RST_STREAM_COMPRESSION_ERROR: |
| 435 return "COMPRESSION_ERROR"; |
438 case RST_STREAM_CONNECT_ERROR: | 436 case RST_STREAM_CONNECT_ERROR: |
439 return "CONNECT_ERROR"; | 437 return "CONNECT_ERROR"; |
440 case RST_STREAM_ENHANCE_YOUR_CALM: | 438 case RST_STREAM_ENHANCE_YOUR_CALM: |
441 return "ENHANCE_YOUR_CALM"; | 439 return "ENHANCE_YOUR_CALM"; |
442 case RST_STREAM_INADEQUATE_SECURITY: | 440 case RST_STREAM_INADEQUATE_SECURITY: |
443 return "INADEQUATE_SECURITY"; | 441 return "INADEQUATE_SECURITY"; |
444 case RST_STREAM_HTTP_1_1_REQUIRED: | 442 case RST_STREAM_HTTP_1_1_REQUIRED: |
445 return "HTTP_1_1_REQUIRED"; | 443 return "HTTP_1_1_REQUIRED"; |
446 } | 444 } |
447 return "UNKNOWN_STATUS"; | 445 return "UNKNOWN_STATUS"; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 // Do we have enough to parse the constant size GOAWAY header? | 1455 // Do we have enough to parse the constant size GOAWAY header? |
1458 if (current_frame_buffer_.len() == header_size) { | 1456 if (current_frame_buffer_.len() == header_size) { |
1459 // Parse out the last good stream id. | 1457 // Parse out the last good stream id. |
1460 SpdyFrameReader reader(current_frame_buffer_.data(), | 1458 SpdyFrameReader reader(current_frame_buffer_.data(), |
1461 current_frame_buffer_.len()); | 1459 current_frame_buffer_.len()); |
1462 reader.Seek(GetFrameHeaderSize()); // Seek past frame header. | 1460 reader.Seek(GetFrameHeaderSize()); // Seek past frame header. |
1463 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); | 1461 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); |
1464 DCHECK(successful_read); | 1462 DCHECK(successful_read); |
1465 | 1463 |
1466 // Parse status code. | 1464 // Parse status code. |
1467 SpdyGoAwayStatus status = GOAWAY_OK; | 1465 SpdyGoAwayStatus status = GOAWAY_NO_ERROR; |
1468 uint32_t status_raw = GOAWAY_OK; | 1466 uint32_t status_raw = GOAWAY_NO_ERROR; |
1469 successful_read = reader.ReadUInt32(&status_raw); | 1467 successful_read = reader.ReadUInt32(&status_raw); |
1470 DCHECK(successful_read); | 1468 DCHECK(successful_read); |
1471 if (IsValidGoAwayStatus(status_raw)) { | 1469 if (IsValidGoAwayStatus(status_raw)) { |
1472 status = ParseGoAwayStatus(status_raw); | 1470 status = ParseGoAwayStatus(status_raw); |
1473 } else { | 1471 } else { |
1474 // Treat unrecognized status codes as INTERNAL_ERROR as | 1472 // Treat unrecognized status codes as INTERNAL_ERROR as |
1475 // recommended by the HTTP/2 spec. | 1473 // recommended by the HTTP/2 spec. |
1476 status = GOAWAY_INTERNAL_ERROR; | 1474 status = GOAWAY_INTERNAL_ERROR; |
1477 } | 1475 } |
1478 // Finished parsing the GOAWAY header, call frame handler. | 1476 // Finished parsing the GOAWAY header, call frame handler. |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 builder->WriteUInt32(header_block.size()); | 2538 builder->WriteUInt32(header_block.size()); |
2541 | 2539 |
2542 // Serialize each header. | 2540 // Serialize each header. |
2543 for (const auto& header : header_block) { | 2541 for (const auto& header : header_block) { |
2544 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2542 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
2545 builder->WriteStringPiece32(header.second); | 2543 builder->WriteStringPiece32(header.second); |
2546 } | 2544 } |
2547 } | 2545 } |
2548 | 2546 |
2549 } // namespace net | 2547 } // namespace net |
OLD | NEW |