OLD | NEW |
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 "webkit/glue/multipart_response_delegate.h" | 5 #include "webkit/glue/multipart_response_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
11 #include "net/http/http_util.h" | 11 #include "net/http/http_util.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade
rVisitor.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade
rVisitor.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" |
| 16 #include "webkit/glue/weburlresponse_extradata_impl.h" |
16 | 17 |
17 using WebKit::WebHTTPHeaderVisitor; | 18 using WebKit::WebHTTPHeaderVisitor; |
18 using WebKit::WebString; | 19 using WebKit::WebString; |
19 using WebKit::WebURLLoader; | 20 using WebKit::WebURLLoader; |
20 using WebKit::WebURLLoaderClient; | 21 using WebKit::WebURLLoaderClient; |
21 using WebKit::WebURLResponse; | 22 using WebKit::WebURLResponse; |
22 | 23 |
23 namespace webkit_glue { | 24 namespace webkit_glue { |
24 | 25 |
25 namespace { | 26 namespace { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 std::string name(kReplaceHeaders[i]); | 261 std::string name(kReplaceHeaders[i]); |
261 std::string value = net::GetSpecificHeader(headers, name); | 262 std::string value = net::GetSpecificHeader(headers, name); |
262 if (!value.empty()) { | 263 if (!value.empty()) { |
263 response.setHTTPHeaderField(WebString::fromUTF8(name), | 264 response.setHTTPHeaderField(WebString::fromUTF8(name), |
264 WebString::fromUTF8(value)); | 265 WebString::fromUTF8(value)); |
265 } | 266 } |
266 } | 267 } |
267 // To avoid recording every multipart load as a separate visit in | 268 // To avoid recording every multipart load as a separate visit in |
268 // the history database, we want to keep track of whether the response | 269 // the history database, we want to keep track of whether the response |
269 // is part of a multipart payload. We do want to record the first visit, | 270 // is part of a multipart payload. We do want to record the first visit, |
270 // so we only set isMultipartPayload to true after the first visit. | 271 // so we only set is_multipart_payload to true after the first visit. |
271 response.setIsMultipartPayload(has_sent_first_response_); | 272 if (response.extraData()) { |
| 273 // extraData can be NULL during tests. |
| 274 WebURLResponseExtraDataImpl* extra_data = |
| 275 static_cast<WebURLResponseExtraDataImpl*>(response.extraData()); |
| 276 extra_data->set_is_multipart_payload(has_sent_first_response_); |
| 277 } |
272 has_sent_first_response_ = true; | 278 has_sent_first_response_ = true; |
| 279 |
273 // Send the response! | 280 // Send the response! |
274 if (client_) | 281 if (client_) |
275 client_->didReceiveResponse(loader_, response); | 282 client_->didReceiveResponse(loader_, response); |
276 | 283 |
277 return true; | 284 return true; |
278 } | 285 } |
279 | 286 |
280 // Boundaries are supposed to be preceeded with --, but it looks like gecko | 287 // Boundaries are supposed to be preceeded with --, but it looks like gecko |
281 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. | 288 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. |
282 size_t MultipartResponseDelegate::FindBoundary() { | 289 size_t MultipartResponseDelegate::FindBoundary() { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (!base::StringToInt64(byte_range_upper_bound, content_range_upper_bound)) | 402 if (!base::StringToInt64(byte_range_upper_bound, content_range_upper_bound)) |
396 return false; | 403 return false; |
397 if (!base::StringToInt64(byte_range_instance_size, | 404 if (!base::StringToInt64(byte_range_instance_size, |
398 content_range_instance_size)) { | 405 content_range_instance_size)) { |
399 return false; | 406 return false; |
400 } | 407 } |
401 return true; | 408 return true; |
402 } | 409 } |
403 | 410 |
404 } // namespace webkit_glue | 411 } // namespace webkit_glue |
OLD | NEW |