OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 DCHECK_EQ(0, read_buf_->offset()); | 527 DCHECK_EQ(0, read_buf_->offset()); |
528 return connection_->socket()->Read(user_read_buf_, user_read_buf_len_, | 528 return connection_->socket()->Read(user_read_buf_, user_read_buf_len_, |
529 &io_callback_); | 529 &io_callback_); |
530 } | 530 } |
531 | 531 |
532 int HttpStreamParser::DoReadBodyComplete(int result) { | 532 int HttpStreamParser::DoReadBodyComplete(int result) { |
533 // If we didn't get a Content-Length and aren't using a chunked encoding, | 533 // If we didn't get a Content-Length and aren't using a chunked encoding, |
534 // the only way to signal the end of a stream is to close the connection, | 534 // the only way to signal the end of a stream is to close the connection, |
535 // so we don't treat that as an error, though in some cases we may not | 535 // so we don't treat that as an error, though in some cases we may not |
536 // have completely received the resource. | 536 // have completely received the resource. |
537 if (result == 0 && !IsResponseBodyComplete() && CanFindEndOfResponse()) | 537 if (result == 0 && !IsResponseBodyComplete() && CanFindEndOfResponse()) { |
538 result = ERR_CONNECTION_CLOSED; | 538 if (chunked_decoder_.get()) |
539 result = ERR_INVALID_CHUNKED_ENCODING; | |
rvargas (doing something else)
2011/11/09 19:55:26
Note that this means we'll be using the same error
cbentzel
2011/11/09 20:40:53
I think it's OK to lump the chunked encoding error
| |
540 else | |
541 result = ERR_CONTENT_LENGTH_MISMATCH; | |
542 } | |
539 | 543 |
540 // Filter incoming data if appropriate. FilterBuf may return an error. | 544 // Filter incoming data if appropriate. FilterBuf may return an error. |
541 if (result > 0 && chunked_decoder_.get()) { | 545 if (result > 0 && chunked_decoder_.get()) { |
542 result = chunked_decoder_->FilterBuf(user_read_buf_->data(), result); | 546 result = chunked_decoder_->FilterBuf(user_read_buf_->data(), result); |
543 if (result == 0 && !chunked_decoder_->reached_eof()) { | 547 if (result == 0 && !chunked_decoder_->reached_eof()) { |
544 // Don't signal completion of the Read call yet or else it'll look like | 548 // Don't signal completion of the Read call yet or else it'll look like |
545 // we received end-of-file. Wait for more data. | 549 // we received end-of-file. Wait for more data. |
546 io_state_ = STATE_READ_BODY; | 550 io_state_ = STATE_READ_BODY; |
547 return OK; | 551 return OK; |
548 } | 552 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 void HttpStreamParser::GetSSLCertRequestInfo( | 766 void HttpStreamParser::GetSSLCertRequestInfo( |
763 SSLCertRequestInfo* cert_request_info) { | 767 SSLCertRequestInfo* cert_request_info) { |
764 if (request_->url.SchemeIs("https") && connection_->socket()) { | 768 if (request_->url.SchemeIs("https") && connection_->socket()) { |
765 SSLClientSocket* ssl_socket = | 769 SSLClientSocket* ssl_socket = |
766 static_cast<SSLClientSocket*>(connection_->socket()); | 770 static_cast<SSLClientSocket*>(connection_->socket()); |
767 ssl_socket->GetSSLCertRequestInfo(cert_request_info); | 771 ssl_socket->GetSSLCertRequestInfo(cert_request_info); |
768 } | 772 } |
769 } | 773 } |
770 | 774 |
771 } // namespace net | 775 } // namespace net |
OLD | NEW |