OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // The rules for parsing content-types were borrowed from Firefox: | 5 // The rules for parsing content-types were borrowed from Firefox: |
6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
7 | 7 |
8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 // Our consumer should have made sure that this is a safe referrer. See for | 668 // Our consumer should have made sure that this is a safe referrer. See for |
669 // instance WebCore::FrameLoader::HideReferrer. | 669 // instance WebCore::FrameLoader::HideReferrer. |
670 if (request_info->referrer.is_valid()) { | 670 if (request_info->referrer.is_valid()) { |
671 request_headers->SetHeader(HttpRequestHeaders::kReferer, | 671 request_headers->SetHeader(HttpRequestHeaders::kReferer, |
672 request_info->referrer.spec()); | 672 request_info->referrer.spec()); |
673 } | 673 } |
674 | 674 |
675 // Add a content length header? | 675 // Add a content length header? |
676 if (upload_data_stream) { | 676 if (upload_data_stream) { |
677 request_headers->SetHeader( | 677 if (upload_data_stream->is_chunked()) { |
678 HttpRequestHeaders::kContentLength, | 678 request_headers->SetHeader( |
679 base::Uint64ToString(upload_data_stream->size())); | 679 HttpRequestHeaders::kTransferEncoding, "chunked"); |
| 680 } else { |
| 681 request_headers->SetHeader( |
| 682 HttpRequestHeaders::kContentLength, |
| 683 base::Uint64ToString(upload_data_stream->size())); |
| 684 } |
680 } else if (request_info->method == "POST" || request_info->method == "PUT" || | 685 } else if (request_info->method == "POST" || request_info->method == "PUT" || |
681 request_info->method == "HEAD") { | 686 request_info->method == "HEAD") { |
682 // An empty POST/PUT request still needs a content length. As for HEAD, | 687 // An empty POST/PUT request still needs a content length. As for HEAD, |
683 // IE and Safari also add a content length header. Presumably it is to | 688 // IE and Safari also add a content length header. Presumably it is to |
684 // support sending a HEAD request to an URL that only expects to be sent a | 689 // support sending a HEAD request to an URL that only expects to be sent a |
685 // POST or some other method that normally would have a message body. | 690 // POST or some other method that normally would have a message body. |
686 request_headers->SetHeader(HttpRequestHeaders::kContentLength, "0"); | 691 request_headers->SetHeader(HttpRequestHeaders::kContentLength, "0"); |
687 } | 692 } |
688 | 693 |
689 // Honor load flags that impact proxy caches. | 694 // Honor load flags that impact proxy caches. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 value_is_quoted_ = true; | 868 value_is_quoted_ = true; |
864 // Do not store iterators into this. See declaration of unquoted_value_. | 869 // Do not store iterators into this. See declaration of unquoted_value_. |
865 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 870 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
866 } | 871 } |
867 } | 872 } |
868 | 873 |
869 return true; | 874 return true; |
870 } | 875 } |
871 | 876 |
872 } // namespace net | 877 } // namespace net |
OLD | NEW |