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

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

Issue 10836084: SPDY - Handle incomplete headers during server push. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_network_transaction_spdy2_unittest.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_http_stream.h" 5 #include "net/spdy/spdy_http_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // TODO(ahendrickson): This is recorded after the entire SYN_STREAM control 404 // TODO(ahendrickson): This is recorded after the entire SYN_STREAM control
405 // frame has been received and processed. Move to framer? 405 // frame has been received and processed. Move to framer?
406 response_info_->response_time = response_time; 406 response_info_->response_time = response_time;
407 407
408 if (!callback_.is_null()) 408 if (!callback_.is_null())
409 DoCallback(status); 409 DoCallback(status);
410 410
411 return status; 411 return status;
412 } 412 }
413 413
414 void SpdyHttpStream::OnDataReceived(const char* data, int length) { 414 int SpdyHttpStream::OnDataReceived(const char* data, int length) {
415 // SpdyStream won't call us with data if the header block didn't contain a 415 // SpdyStream won't call us with data if the header block didn't contain a
416 // valid set of headers. So we don't expect to not have headers received 416 // valid set of headers. So we don't expect to not have headers received
417 // here. 417 // here.
418 DCHECK(response_headers_received_); 418 if (!response_headers_received_)
419 return ERR_INCOMPLETE_SPDY_HEADERS;
419 420
420 // Note that data may be received for a SpdyStream prior to the user calling 421 // Note that data may be received for a SpdyStream prior to the user calling
421 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often 422 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often
422 // happen for server initiated streams. 423 // happen for server initiated streams.
423 DCHECK(!stream_->closed() || stream_->pushed()); 424 DCHECK(!stream_->closed() || stream_->pushed());
424 if (length > 0) { 425 if (length > 0) {
425 // Save the received data. 426 // Save the received data.
426 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); 427 IOBufferWithSize* io_buffer = new IOBufferWithSize(length);
427 memcpy(io_buffer->data(), data, length); 428 memcpy(io_buffer->data(), data, length);
428 response_body_.push_back(make_scoped_refptr(io_buffer)); 429 response_body_.push_back(make_scoped_refptr(io_buffer));
429 430
430 if (user_buffer_) { 431 if (user_buffer_) {
431 // Handing small chunks of data to the caller creates measurable overhead. 432 // Handing small chunks of data to the caller creates measurable overhead.
432 // We buffer data in short time-spans and send a single read notification. 433 // We buffer data in short time-spans and send a single read notification.
433 ScheduleBufferedReadCallback(); 434 ScheduleBufferedReadCallback();
434 } 435 }
435 } 436 }
437 return OK;
436 } 438 }
437 439
438 void SpdyHttpStream::OnDataSent(int length) { 440 void SpdyHttpStream::OnDataSent(int length) {
439 // For HTTP streams, no data is sent from the client while in the OPEN state, 441 // For HTTP streams, no data is sent from the client while in the OPEN state,
440 // so it is never called. 442 // so it is never called.
441 NOTREACHED(); 443 NOTREACHED();
442 } 444 }
443 445
444 void SpdyHttpStream::OnClose(int status) { 446 void SpdyHttpStream::OnClose(int status) {
445 bool invoked_callback = false; 447 bool invoked_callback = false;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 bool SpdyHttpStream::IsSpdyHttpStream() const { 552 bool SpdyHttpStream::IsSpdyHttpStream() const {
551 return true; 553 return true;
552 } 554 }
553 555
554 void SpdyHttpStream::Drain(HttpNetworkSession* session) { 556 void SpdyHttpStream::Drain(HttpNetworkSession* session) {
555 Close(false); 557 Close(false);
556 delete this; 558 delete this;
557 } 559 }
558 560
559 } // namespace net 561 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698