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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 case 204: // No Content | 714 case 204: // No Content |
715 case 205: // Reset Content | 715 case 205: // Reset Content |
716 case 304: // Not Modified | 716 case 304: // Not Modified |
717 response_body_length_ = 0; | 717 response_body_length_ = 0; |
718 break; | 718 break; |
719 } | 719 } |
720 if (request_->method == "HEAD") | 720 if (request_->method == "HEAD") |
721 response_body_length_ = 0; | 721 response_body_length_ = 0; |
722 | 722 |
723 if (response_body_length_ == -1) { | 723 if (response_body_length_ == -1) { |
724 // Ignore spurious chunked responses from HTTP/1.0 servers and | 724 // "Transfer-Encoding: chunked" trumps "Content-Length: N" |
725 // proxies. Otherwise "Transfer-Encoding: chunked" trumps | 725 if (response_->headers->IsChunkEncoded()) { |
726 // "Content-Length: N" | |
727 if (response_->headers->GetHttpVersion() >= HttpVersion(1, 1) && | |
728 response_->headers->HasHeaderValue("Transfer-Encoding", "chunked")) { | |
729 chunked_decoder_.reset(new HttpChunkedDecoder()); | 726 chunked_decoder_.reset(new HttpChunkedDecoder()); |
730 } else { | 727 } else { |
731 response_body_length_ = response_->headers->GetContentLength(); | 728 response_body_length_ = response_->headers->GetContentLength(); |
732 // If response_body_length_ is still -1, then we have to wait | 729 // If response_body_length_ is still -1, then we have to wait |
733 // for the server to close the connection. | 730 // for the server to close the connection. |
734 } | 731 } |
735 } | 732 } |
736 } | 733 } |
737 | 734 |
738 uint64 HttpStreamParser::GetUploadProgress() const { | 735 uint64 HttpStreamParser::GetUploadProgress() const { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 void HttpStreamParser::GetSSLCertRequestInfo( | 785 void HttpStreamParser::GetSSLCertRequestInfo( |
789 SSLCertRequestInfo* cert_request_info) { | 786 SSLCertRequestInfo* cert_request_info) { |
790 if (request_->url.SchemeIs("https") && connection_->socket()) { | 787 if (request_->url.SchemeIs("https") && connection_->socket()) { |
791 SSLClientSocket* ssl_socket = | 788 SSLClientSocket* ssl_socket = |
792 static_cast<SSLClientSocket*>(connection_->socket()); | 789 static_cast<SSLClientSocket*>(connection_->socket()); |
793 ssl_socket->GetSSLCertRequestInfo(cert_request_info); | 790 ssl_socket->GetSSLCertRequestInfo(cert_request_info); |
794 } | 791 } |
795 } | 792 } |
796 | 793 |
797 } // namespace net | 794 } // namespace net |
OLD | NEW |