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

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

Issue 1272283003: Add a new SpdyStream::Delegate method to handle trailers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add NOTREACHED Created 5 years, 4 months 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_stream.h ('k') | net/spdy/spdy_stream_test_util.h » ('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_stream.h" 5 #include "net/spdy/spdy_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) { 50 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) {
51 if (*i >= 'A' && *i <= 'Z') { 51 if (*i >= 'A' && *i <= 'Z') {
52 return true; 52 return true;
53 } 53 }
54 } 54 }
55 return false; 55 return false;
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
60 void SpdyStream::Delegate::OnTrailers(const SpdyHeaderBlock& trailers) {}
61
60 // A wrapper around a stream that calls into ProduceSynStreamFrame(). 62 // A wrapper around a stream that calls into ProduceSynStreamFrame().
61 class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer { 63 class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer {
62 public: 64 public:
63 SynStreamBufferProducer(const base::WeakPtr<SpdyStream>& stream) 65 SynStreamBufferProducer(const base::WeakPtr<SpdyStream>& stream)
64 : stream_(stream) { 66 : stream_(stream) {
65 DCHECK(stream_.get()); 67 DCHECK(stream_.get());
66 } 68 }
67 69
68 ~SynStreamBufferProducer() override {} 70 ~SynStreamBufferProducer() override {}
69 71
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DCHECK_NE(io_state_, STATE_IDLE); 435 DCHECK_NE(io_state_, STATE_IDLE);
434 436
435 response_time_ = response_time; 437 response_time_ = response_time;
436 recv_first_byte_time_ = recv_first_byte_time; 438 recv_first_byte_time_ = recv_first_byte_time;
437 return MergeWithResponseHeaders(initial_response_headers); 439 return MergeWithResponseHeaders(initial_response_headers);
438 } 440 }
439 441
440 int SpdyStream::OnAdditionalResponseHeadersReceived( 442 int SpdyStream::OnAdditionalResponseHeadersReceived(
441 const SpdyHeaderBlock& additional_response_headers) { 443 const SpdyHeaderBlock& additional_response_headers) {
442 if (type_ == SPDY_REQUEST_RESPONSE_STREAM) { 444 if (type_ == SPDY_REQUEST_RESPONSE_STREAM) {
443 session_->ResetStream( 445 if (response_headers_status_ != RESPONSE_HEADERS_ARE_COMPLETE) {
444 stream_id_, RST_STREAM_PROTOCOL_ERROR, 446 session_->ResetStream(
445 "Additional headers received for request/response stream"); 447 stream_id_, RST_STREAM_PROTOCOL_ERROR,
446 return ERR_SPDY_PROTOCOL_ERROR; 448 "Additional headers received for request/response stream");
447 } else if (type_ == SPDY_PUSH_STREAM && 449 return ERR_SPDY_PROTOCOL_ERROR;
448 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) { 450 }
451 response_headers_status_ = TRAILERS_RECEIVED;
452 delegate_->OnTrailers(additional_response_headers);
453 return OK;
454 }
455 if (type_ == SPDY_PUSH_STREAM &&
456 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
449 session_->ResetStream( 457 session_->ResetStream(
450 stream_id_, RST_STREAM_PROTOCOL_ERROR, 458 stream_id_, RST_STREAM_PROTOCOL_ERROR,
451 "Additional headers received for push stream"); 459 "Additional headers received for push stream");
452 return ERR_SPDY_PROTOCOL_ERROR; 460 return ERR_SPDY_PROTOCOL_ERROR;
453 } 461 }
454 return MergeWithResponseHeaders(additional_response_headers); 462 return MergeWithResponseHeaders(additional_response_headers);
455 } 463 }
456 464
457 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) { 465 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) {
458 CHECK(!request_headers_.get()); 466 CHECK(!request_headers_.get());
(...skipping 18 matching lines...) Expand all
477 if (buffer) { 485 if (buffer) {
478 pending_recv_data_.push_back(buffer.Pass()); 486 pending_recv_data_.push_back(buffer.Pass());
479 } else { 487 } else {
480 pending_recv_data_.push_back(NULL); 488 pending_recv_data_.push_back(NULL);
481 // Note: we leave the stream open in the session until the stream 489 // Note: we leave the stream open in the session until the stream
482 // is claimed. 490 // is claimed.
483 } 491 }
484 return; 492 return;
485 } 493 }
486 494
495 if (response_headers_status_ == TRAILERS_RECEIVED && buffer) {
496 // TRAILERS_RECEIVED is only used in SPDY_REQUEST_RESPONSE_STREAM.
497 DCHECK_EQ(type_, SPDY_REQUEST_RESPONSE_STREAM);
498 session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR,
499 "Data received after trailers");
500 return;
501 }
502
487 // If we have response headers but the delegate has indicated that 503 // If we have response headers but the delegate has indicated that
488 // it's still incomplete, then that's a protocol error. 504 // it's still incomplete, then that's a protocol error.
489 if (response_headers_status_ == RESPONSE_HEADERS_ARE_INCOMPLETE) { 505 if (response_headers_status_ == RESPONSE_HEADERS_ARE_INCOMPLETE) {
490 LogStreamError(ERR_SPDY_PROTOCOL_ERROR, 506 LogStreamError(ERR_SPDY_PROTOCOL_ERROR,
491 "Data received with incomplete headers."); 507 "Data received with incomplete headers.");
492 session_->CloseActiveStream(stream_id_, ERR_SPDY_PROTOCOL_ERROR); 508 session_->CloseActiveStream(stream_id_, ERR_SPDY_PROTOCOL_ERROR);
493 return; 509 return;
494 } 510 }
495 511
496 CHECK(!IsClosed()); 512 CHECK(!IsClosed());
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 935 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
920 state); 936 state);
921 break; 937 break;
922 } 938 }
923 return description; 939 return description;
924 } 940 }
925 941
926 #undef STATE_CASE 942 #undef STATE_CASE
927 943
928 } // namespace net 944 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698