Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 1461273003: Remove already obsolete CREDENTIAL frame from SPDY code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iterator> 10 #include <iterator>
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 size_t SpdyFramer::GetControlFrameHeaderSize() const { 230 size_t SpdyFramer::GetControlFrameHeaderSize() const {
231 return SpdyConstants::GetControlFrameHeaderSize(protocol_version()); 231 return SpdyConstants::GetControlFrameHeaderSize(protocol_version());
232 } 232 }
233 233
234 size_t SpdyFramer::GetSynStreamMinimumSize() const { 234 size_t SpdyFramer::GetSynStreamMinimumSize() const {
235 // Size, in bytes, of a SYN_STREAM frame not including the variable-length 235 // Size, in bytes, of a SYN_STREAM frame not including the variable-length
236 // header block. 236 // header block.
237 if (protocol_version() <= SPDY3) { 237 if (protocol_version() <= SPDY3) {
238 // Calculated as: 238 // Calculated as:
239 // control frame header + 2 * 4 (stream IDs) + 1 (priority) 239 // control frame header + 2 * 4 (stream IDs) + 1 (priority)
240 // + 1 (unused, was credential slot) 240 // + 1 (unused)
241 return GetControlFrameHeaderSize() + 10; 241 return GetControlFrameHeaderSize() + 10;
242 } else { 242 } else {
243 return GetControlFrameHeaderSize() + 243 return GetControlFrameHeaderSize() +
244 kPriorityDependencyPayloadSize + 244 kPriorityDependencyPayloadSize +
245 kPriorityWeightPayloadSize; 245 kPriorityWeightPayloadSize;
246 } 246 }
247 } 247 }
248 248
249 size_t SpdyFramer::GetSynReplyMinimumSize() const { 249 size_t SpdyFramer::GetSynReplyMinimumSize() const {
250 // Size, in bytes, of a SYN_REPLY frame not including the variable-length 250 // Size, in bytes, of a SYN_REPLY frame not including the variable-length
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 case RST_STREAM_CANCEL: 490 case RST_STREAM_CANCEL:
491 return "CANCEL"; 491 return "CANCEL";
492 case RST_STREAM_INTERNAL_ERROR: 492 case RST_STREAM_INTERNAL_ERROR:
493 return "INTERNAL_ERROR"; 493 return "INTERNAL_ERROR";
494 case RST_STREAM_FLOW_CONTROL_ERROR: 494 case RST_STREAM_FLOW_CONTROL_ERROR:
495 return "FLOW_CONTROL_ERROR"; 495 return "FLOW_CONTROL_ERROR";
496 case RST_STREAM_STREAM_IN_USE: 496 case RST_STREAM_STREAM_IN_USE:
497 return "STREAM_IN_USE"; 497 return "STREAM_IN_USE";
498 case RST_STREAM_STREAM_ALREADY_CLOSED: 498 case RST_STREAM_STREAM_ALREADY_CLOSED:
499 return "STREAM_ALREADY_CLOSED"; 499 return "STREAM_ALREADY_CLOSED";
500 case RST_STREAM_INVALID_CREDENTIALS:
501 return "INVALID_CREDENTIALS";
502 case RST_STREAM_FRAME_TOO_LARGE: 500 case RST_STREAM_FRAME_TOO_LARGE:
503 return "FRAME_TOO_LARGE"; 501 return "FRAME_TOO_LARGE";
504 case RST_STREAM_CONNECT_ERROR: 502 case RST_STREAM_CONNECT_ERROR:
505 return "CONNECT_ERROR"; 503 return "CONNECT_ERROR";
506 case RST_STREAM_ENHANCE_YOUR_CALM: 504 case RST_STREAM_ENHANCE_YOUR_CALM:
507 return "ENHANCE_YOUR_CALM"; 505 return "ENHANCE_YOUR_CALM";
508 case RST_STREAM_INADEQUATE_SECURITY: 506 case RST_STREAM_INADEQUATE_SECURITY:
509 return "INADEQUATE_SECURITY"; 507 return "INADEQUATE_SECURITY";
510 case RST_STREAM_HTTP_1_1_REQUIRED: 508 case RST_STREAM_HTTP_1_1_REQUIRED:
511 return "HTTP_1_1_REQUIRED"; 509 return "HTTP_1_1_REQUIRED";
(...skipping 14 matching lines...) Expand all
526 case SETTINGS: 524 case SETTINGS:
527 return "SETTINGS"; 525 return "SETTINGS";
528 case PING: 526 case PING:
529 return "PING"; 527 return "PING";
530 case GOAWAY: 528 case GOAWAY:
531 return "GOAWAY"; 529 return "GOAWAY";
532 case HEADERS: 530 case HEADERS:
533 return "HEADERS"; 531 return "HEADERS";
534 case WINDOW_UPDATE: 532 case WINDOW_UPDATE:
535 return "WINDOW_UPDATE"; 533 return "WINDOW_UPDATE";
536 case CREDENTIAL:
537 return "CREDENTIAL";
538 case PUSH_PROMISE: 534 case PUSH_PROMISE:
539 return "PUSH_PROMISE"; 535 return "PUSH_PROMISE";
540 case CONTINUATION: 536 case CONTINUATION:
541 return "CONTINUATION"; 537 return "CONTINUATION";
542 case PRIORITY: 538 case PRIORITY:
543 return "PRIORITY"; 539 return "PRIORITY";
544 case ALTSVC: 540 case ALTSVC:
545 return "ALTSVC"; 541 return "ALTSVC";
546 case BLOCKED: 542 case BLOCKED:
547 return "BLOCKED"; 543 return "BLOCKED";
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 ProcessControlFrameHeader(control_frame_type_field); 879 ProcessControlFrameHeader(control_frame_type_field);
884 } 880 }
885 881
886 return original_len - len; 882 return original_len - len;
887 } 883 }
888 884
889 void SpdyFramer::ProcessControlFrameHeader(int control_frame_type_field) { 885 void SpdyFramer::ProcessControlFrameHeader(int control_frame_type_field) {
890 DCHECK_EQ(SPDY_NO_ERROR, error_code_); 886 DCHECK_EQ(SPDY_NO_ERROR, error_code_);
891 DCHECK_LE(GetControlFrameHeaderSize(), current_frame_buffer_.len()); 887 DCHECK_LE(GetControlFrameHeaderSize(), current_frame_buffer_.len());
892 888
893 // TODO(mlavan): Either remove credential frames from the code entirely,
894 // or add them to parsing + serialization methods for SPDY3.
895 // Early detection of deprecated frames that we ignore.
896 if (protocol_version() <= SPDY3) {
897 if (control_frame_type_field == CREDENTIAL) {
898 current_frame_type_ = CREDENTIAL;
899 DCHECK_EQ(SPDY3, protocol_version());
900 DVLOG(1) << "CREDENTIAL control frame found. Ignoring.";
901 CHANGE_STATE(SPDY_IGNORE_REMAINING_PAYLOAD);
902 return;
903 }
904 }
905
906 if (!SpdyConstants::IsValidFrameType(protocol_version(), 889 if (!SpdyConstants::IsValidFrameType(protocol_version(),
907 control_frame_type_field)) { 890 control_frame_type_field)) {
908 if (protocol_version() <= SPDY3) { 891 if (protocol_version() <= SPDY3) {
909 DLOG(WARNING) << "Invalid control frame type " << control_frame_type_field 892 DLOG(WARNING) << "Invalid control frame type " << control_frame_type_field
910 << " (protocol version: " << protocol_version() << ")"; 893 << " (protocol version: " << protocol_version() << ")";
911 set_error(SPDY_INVALID_CONTROL_FRAME); 894 set_error(SPDY_INVALID_CONTROL_FRAME);
912 return; 895 return;
913 } else { 896 } else {
914 // In HTTP2 we ignore unknown frame types for extensibility, as long as 897 // In HTTP2 we ignore unknown frame types for extensibility, as long as
915 // the rest of the control frame header is valid. 898 // the rest of the control frame header is valid.
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 1440
1458 SpdyPriority priority = 0; 1441 SpdyPriority priority = 0;
1459 successful_read = reader.ReadUInt8(&priority); 1442 successful_read = reader.ReadUInt8(&priority);
1460 DCHECK(successful_read); 1443 DCHECK(successful_read);
1461 if (protocol_version() <= SPDY2) { 1444 if (protocol_version() <= SPDY2) {
1462 priority = priority >> 6; 1445 priority = priority >> 6;
1463 } else { 1446 } else {
1464 priority = priority >> 5; 1447 priority = priority >> 5;
1465 } 1448 }
1466 1449
1467 // Seek past unused byte; used to be credential slot in SPDY 3. 1450 // Seek past unused byte.
1468 reader.Seek(1); 1451 reader.Seek(1);
1469 1452
1470 DCHECK(reader.IsDoneReading()); 1453 DCHECK(reader.IsDoneReading());
1471 if (debug_visitor_) { 1454 if (debug_visitor_) {
1472 debug_visitor_->OnReceiveCompressedFrame( 1455 debug_visitor_->OnReceiveCompressedFrame(
1473 current_frame_stream_id_, 1456 current_frame_stream_id_,
1474 current_frame_type_, 1457 current_frame_type_,
1475 current_frame_length_); 1458 current_frame_length_);
1476 } 1459 }
1477 visitor_->OnSynStream( 1460 visitor_->OnSynStream(
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 2353
2371 // The size of this frame, including variable-length header block. 2354 // The size of this frame, including variable-length header block.
2372 size_t size = GetSynStreamMinimumSize() + 2355 size_t size = GetSynStreamMinimumSize() +
2373 GetSerializedLength(syn_stream.header_block()); 2356 GetSerializedLength(syn_stream.header_block());
2374 2357
2375 SpdyFrameBuilder builder(size, protocol_version()); 2358 SpdyFrameBuilder builder(size, protocol_version());
2376 builder.WriteControlFrameHeader(*this, SYN_STREAM, flags); 2359 builder.WriteControlFrameHeader(*this, SYN_STREAM, flags);
2377 builder.WriteUInt32(syn_stream.stream_id()); 2360 builder.WriteUInt32(syn_stream.stream_id());
2378 builder.WriteUInt32(syn_stream.associated_to_stream_id()); 2361 builder.WriteUInt32(syn_stream.associated_to_stream_id());
2379 builder.WriteUInt8(priority << ((protocol_version() <= SPDY2) ? 6 : 5)); 2362 builder.WriteUInt8(priority << ((protocol_version() <= SPDY2) ? 6 : 5));
2380 builder.WriteUInt8(0); // Unused byte where credential slot used to be. 2363 builder.WriteUInt8(0); // Unused byte.
2381 DCHECK_EQ(GetSynStreamMinimumSize(), builder.length()); 2364 DCHECK_EQ(GetSynStreamMinimumSize(), builder.length());
2382 SerializeHeaderBlock(&builder, syn_stream); 2365 SerializeHeaderBlock(&builder, syn_stream);
2383 2366
2384 if (debug_visitor_) { 2367 if (debug_visitor_) {
2385 const size_t payload_len = 2368 const size_t payload_len =
2386 GetSerializedLength(protocol_version(), &(syn_stream.header_block())); 2369 GetSerializedLength(protocol_version(), &(syn_stream.header_block()));
2387 debug_visitor_->OnSendCompressedFrame(syn_stream.stream_id(), 2370 debug_visitor_->OnSendCompressedFrame(syn_stream.stream_id(),
2388 SYN_STREAM, 2371 SYN_STREAM,
2389 payload_len, 2372 payload_len,
2390 builder.length()); 2373 builder.length());
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 #else 3223 #else
3241 WriteHeaderBlockToZ(&frame.header_block(), compressor); 3224 WriteHeaderBlockToZ(&frame.header_block(), compressor);
3242 #endif // defined(USE_SYSTEM_ZLIB) 3225 #endif // defined(USE_SYSTEM_ZLIB)
3243 3226
3244 int compressed_size = compressed_max_size - compressor->avail_out; 3227 int compressed_size = compressed_max_size - compressor->avail_out;
3245 builder->Seek(compressed_size); 3228 builder->Seek(compressed_size);
3246 builder->RewriteLength(*this); 3229 builder->RewriteLength(*this);
3247 } 3230 }
3248 3231
3249 } // namespace net 3232 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698