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

Side by Side Diff: net/http/http_network_transaction.cc

Issue 63139: Add a boolean data member called_socket_read_ to help... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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/http/http_network_transaction.h ('k') | net/http/http_network_transaction_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/field_trial.h" 9 #include "base/field_trial.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 session_(session), 42 session_(session),
43 request_(NULL), 43 request_(NULL),
44 pac_request_(NULL), 44 pac_request_(NULL),
45 socket_factory_(csf), 45 socket_factory_(csf),
46 connection_(session->connection_pool()), 46 connection_(session->connection_pool()),
47 reused_socket_(false), 47 reused_socket_(false),
48 using_ssl_(false), 48 using_ssl_(false),
49 using_proxy_(false), 49 using_proxy_(false),
50 using_tunnel_(false), 50 using_tunnel_(false),
51 establishing_tunnel_(false), 51 establishing_tunnel_(false),
52 reading_body_from_socket_(false),
52 request_headers_bytes_sent_(0), 53 request_headers_bytes_sent_(0),
53 header_buf_capacity_(0), 54 header_buf_capacity_(0),
54 header_buf_len_(0), 55 header_buf_len_(0),
55 header_buf_body_offset_(-1), 56 header_buf_body_offset_(-1),
56 header_buf_http_offset_(-1), 57 header_buf_http_offset_(-1),
57 response_body_length_(-1), // -1 means unspecified. 58 response_body_length_(-1), // -1 means unspecified.
58 response_body_read_(0), 59 response_body_read_(0),
59 read_buf_len_(0), 60 read_buf_len_(0),
60 next_state_(STATE_NONE) { 61 next_state_(STATE_NONE) {
61 #if defined(OS_WIN) 62 #if defined(OS_WIN)
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 header_buf_body_offset_ += n; 826 header_buf_body_offset_ += n;
826 if (header_buf_body_offset_ == header_buf_len_) { 827 if (header_buf_body_offset_ == header_buf_len_) {
827 header_buf_.reset(); 828 header_buf_.reset();
828 header_buf_capacity_ = 0; 829 header_buf_capacity_ = 0;
829 header_buf_len_ = 0; 830 header_buf_len_ = 0;
830 header_buf_body_offset_ = -1; 831 header_buf_body_offset_ = -1;
831 } 832 }
832 return n; 833 return n;
833 } 834 }
834 835
836 reading_body_from_socket_ = true;
835 return connection_.socket()->Read(read_buf_->data(), read_buf_len_, 837 return connection_.socket()->Read(read_buf_->data(), read_buf_len_,
836 &io_callback_); 838 &io_callback_);
837 } 839 }
838 840
839 int HttpNetworkTransaction::DoReadBodyComplete(int result) { 841 int HttpNetworkTransaction::DoReadBodyComplete(int result) {
840 // We are done with the Read call. 842 // We are done with the Read call.
841 DCHECK(!establishing_tunnel_) << 843 DCHECK(!establishing_tunnel_) <<
842 "We should never read a response body of a tunnel."; 844 "We should never read a response body of a tunnel.";
843 845
844 bool unfiltered_eof = (result == 0); 846 bool unfiltered_eof = (result == 0 && reading_body_from_socket_);
847 reading_body_from_socket_ = false;
845 848
846 // Filter incoming data if appropriate. FilterBuf may return an error. 849 // Filter incoming data if appropriate. FilterBuf may return an error.
847 if (result > 0 && chunked_decoder_.get()) { 850 if (result > 0 && chunked_decoder_.get()) {
848 result = chunked_decoder_->FilterBuf(read_buf_->data(), result); 851 result = chunked_decoder_->FilterBuf(read_buf_->data(), result);
849 if (result == 0 && !chunked_decoder_->reached_eof()) { 852 if (result == 0 && !chunked_decoder_->reached_eof()) {
850 // Don't signal completion of the Read call yet or else it'll look like 853 // Don't signal completion of the Read call yet or else it'll look like
851 // we received end-of-file. Wait for more data. 854 // we received end-of-file. Wait for more data.
852 next_state_ = STATE_READ_BODY; 855 next_state_ = STATE_READ_BODY;
853 return OK; 856 return OK;
854 } 857 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 int rv = DoReadBody(); 901 int rv = DoReadBody();
899 DCHECK(next_state_ == STATE_READ_BODY_COMPLETE); 902 DCHECK(next_state_ == STATE_READ_BODY_COMPLETE);
900 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE; 903 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE;
901 return rv; 904 return rv;
902 } 905 }
903 906
904 // TODO(wtc): The first two thirds of this method and the DoReadBodyComplete 907 // TODO(wtc): The first two thirds of this method and the DoReadBodyComplete
905 // method are almost the same. Figure out a good way for these two methods 908 // method are almost the same. Figure out a good way for these two methods
906 // to share code. 909 // to share code.
907 int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) { 910 int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) {
908 bool unfiltered_eof = (result == 0); 911 bool unfiltered_eof = (result == 0 && reading_body_from_socket_);
912 reading_body_from_socket_ = false;
909 913
910 // Filter incoming data if appropriate. FilterBuf may return an error. 914 // Filter incoming data if appropriate. FilterBuf may return an error.
911 if (result > 0 && chunked_decoder_.get()) { 915 if (result > 0 && chunked_decoder_.get()) {
912 result = chunked_decoder_->FilterBuf(read_buf_->data(), result); 916 result = chunked_decoder_->FilterBuf(read_buf_->data(), result);
913 if (result == 0 && !chunked_decoder_->reached_eof()) { 917 if (result == 0 && !chunked_decoder_->reached_eof()) {
914 // Don't signal completion of the Read call yet or else it'll look like 918 // Don't signal completion of the Read call yet or else it'll look like
915 // we received end-of-file. Wait for more data. 919 // we received end-of-file. Wait for more data.
916 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART; 920 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART;
917 return OK; 921 return OK;
918 } 922 }
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 if (target == HttpAuth::AUTH_PROXY) { 1532 if (target == HttpAuth::AUTH_PROXY) {
1529 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port()); 1533 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port());
1530 } else { 1534 } else {
1531 DCHECK(target == HttpAuth::AUTH_SERVER); 1535 DCHECK(target == HttpAuth::AUTH_SERVER);
1532 auth_info->host = ASCIIToWide(request_->url.host()); 1536 auth_info->host = ASCIIToWide(request_->url.host());
1533 } 1537 }
1534 response_.auth_challenge = auth_info; 1538 response_.auth_challenge = auth_info;
1535 } 1539 }
1536 1540
1537 } // namespace net 1541 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698