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

Side by Side Diff: content/common/net/url_fetcher_impl.cc

Issue 9342007: Add HTTP PUT request type to content:URLFetcher (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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 | « content/common/net/url_fetcher_impl.h ('k') | content/public/common/url_fetcher.h » ('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 "content/common/net/url_fetcher_impl.h" 5 #include "content/common/net/url_fetcher_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 request_->EnableChunkedUpload(); 791 request_->EnableChunkedUpload();
792 request_->set_load_flags(flags); 792 request_->set_load_flags(flags);
793 request_->set_context(request_context_getter_->GetURLRequestContext()); 793 request_->set_context(request_context_getter_->GetURLRequestContext());
794 request_->set_referrer(referrer_); 794 request_->set_referrer(referrer_);
795 795
796 switch (request_type_) { 796 switch (request_type_) {
797 case GET: 797 case GET:
798 break; 798 break;
799 799
800 case POST: 800 case POST:
801 case PUT:
801 DCHECK(!upload_content_.empty() || is_chunked_upload_); 802 DCHECK(!upload_content_.empty() || is_chunked_upload_);
802 DCHECK(!upload_content_type_.empty()); 803 DCHECK(!upload_content_type_.empty());
803 804
804 request_->set_method("POST"); 805 request_->set_method(request_type_ == POST ? "POST" : "PUT");
805 extra_request_headers_.SetHeader(net::HttpRequestHeaders::kContentType, 806 extra_request_headers_.SetHeader(net::HttpRequestHeaders::kContentType,
806 upload_content_type_); 807 upload_content_type_);
807 if (!upload_content_.empty()) { 808 if (!upload_content_.empty()) {
808 request_->AppendBytesToUpload( 809 request_->AppendBytesToUpload(
809 upload_content_.data(), static_cast<int>(upload_content_.length())); 810 upload_content_.data(), static_cast<int>(upload_content_.length()));
810 } 811 }
811 break; 812 break;
812 813
813 case HEAD: 814 case HEAD:
814 request_->set_method("HEAD"); 815 request_->set_method("HEAD");
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 int URLFetcherImpl::GetLoadFlags() const { 969 int URLFetcherImpl::GetLoadFlags() const {
969 return core_->load_flags_; 970 return core_->load_flags_;
970 } 971 }
971 972
972 void URLFetcherImpl::SetExtraRequestHeaders( 973 void URLFetcherImpl::SetExtraRequestHeaders(
973 const std::string& extra_request_headers) { 974 const std::string& extra_request_headers) {
974 core_->extra_request_headers_.Clear(); 975 core_->extra_request_headers_.Clear();
975 core_->extra_request_headers_.AddHeadersFromString(extra_request_headers); 976 core_->extra_request_headers_.AddHeadersFromString(extra_request_headers);
976 } 977 }
977 978
979 void URLFetcherImpl::AddExtraRequestHeader(const std::string& header_line) {
980 core_->extra_request_headers_.AddHeaderFromString(header_line);
981 }
982
978 void URLFetcherImpl::GetExtraRequestHeaders(net::HttpRequestHeaders* headers) { 983 void URLFetcherImpl::GetExtraRequestHeaders(net::HttpRequestHeaders* headers) {
979 headers->CopyFrom(core_->extra_request_headers_); 984 headers->CopyFrom(core_->extra_request_headers_);
980 } 985 }
981 986
982 void URLFetcherImpl::SetRequestContext( 987 void URLFetcherImpl::SetRequestContext(
983 net::URLRequestContextGetter* request_context_getter) { 988 net::URLRequestContextGetter* request_context_getter) {
984 DCHECK(!core_->request_context_getter_); 989 DCHECK(!core_->request_context_getter_);
985 core_->request_context_getter_ = request_context_getter; 990 core_->request_context_getter_ = request_context_getter;
986 } 991 }
987 992
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1131
1127 // static 1132 // static
1128 content::URLFetcherFactory* URLFetcherImpl::factory() { 1133 content::URLFetcherFactory* URLFetcherImpl::factory() {
1129 return g_factory; 1134 return g_factory;
1130 } 1135 }
1131 1136
1132 // static 1137 // static
1133 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { 1138 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) {
1134 g_factory = factory; 1139 g_factory = factory;
1135 } 1140 }
OLDNEW
« no previous file with comments | « content/common/net/url_fetcher_impl.h ('k') | content/public/common/url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698