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 #include "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void URLRequest::SetExtraRequestHeaderById(int id, const string& value, | 175 void URLRequest::SetExtraRequestHeaderById(int id, const string& value, |
176 bool overwrite) { | 176 bool overwrite) { |
177 DCHECK(!is_pending_); | 177 DCHECK(!is_pending_); |
178 NOTREACHED() << "implement me!"; | 178 NOTREACHED() << "implement me!"; |
179 } | 179 } |
180 | 180 |
181 void URLRequest::SetExtraRequestHeaderByName(const string& name, | 181 void URLRequest::SetExtraRequestHeaderByName(const string& name, |
182 const string& value, | 182 const string& value, |
183 bool overwrite) { | 183 bool overwrite) { |
184 DCHECK(!is_pending_); | 184 DCHECK(!is_pending_); |
185 NOTREACHED() << "implement me!"; | 185 if (!overwrite || !extra_request_headers_.HasHeader(name)) |
| 186 extra_request_headers_.SetHeader(name, value); |
186 } | 187 } |
187 | 188 |
188 void URLRequest::SetExtraRequestHeaders( | 189 void URLRequest::SetExtraRequestHeaders( |
189 const net::HttpRequestHeaders& headers) { | 190 const net::HttpRequestHeaders& headers) { |
190 DCHECK(!is_pending_); | 191 DCHECK(!is_pending_); |
191 extra_request_headers_ = headers; | 192 extra_request_headers_.MergeFrom(headers); |
192 | 193 |
193 // NOTE: This method will likely become non-trivial once the other setters | 194 // NOTE: This method will likely become non-trivial once the other setters |
194 // for request headers are implemented. | 195 // for request headers are implemented. |
195 } | 196 } |
196 | 197 |
197 net::LoadState URLRequest::GetLoadState() const { | 198 net::LoadState URLRequest::GetLoadState() const { |
198 return job_ ? job_->GetLoadState() : net::LOAD_STATE_IDLE; | 199 return job_ ? job_->GetLoadState() : net::LOAD_STATE_IDLE; |
199 } | 200 } |
200 | 201 |
201 uint64 URLRequest::GetUploadProgress() const { | 202 uint64 URLRequest::GetUploadProgress() const { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { | 580 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { |
580 UserDataMap::const_iterator found = user_data_.find(key); | 581 UserDataMap::const_iterator found = user_data_.find(key); |
581 if (found != user_data_.end()) | 582 if (found != user_data_.end()) |
582 return found->second.get(); | 583 return found->second.get(); |
583 return NULL; | 584 return NULL; |
584 } | 585 } |
585 | 586 |
586 void URLRequest::SetUserData(const void* key, UserData* data) { | 587 void URLRequest::SetUserData(const void* key, UserData* data) { |
587 user_data_[key] = linked_ptr<UserData>(data); | 588 user_data_[key] = linked_ptr<UserData>(data); |
588 } | 589 } |
OLD | NEW |