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 "chrome_frame/urlmon_url_request.h" | 5 #include "chrome_frame/urlmon_url_request.h" |
6 | 6 |
7 #include <urlmon.h> | 7 #include <urlmon.h> |
8 #include <wininet.h> | 8 #include <wininet.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 << " assigned id " << request_id; | 1067 << " assigned id " << request_id; |
1068 } | 1068 } |
1069 } | 1069 } |
1070 | 1070 |
1071 if (!is_started) { | 1071 if (!is_started) { |
1072 CComObject<UrlmonUrlRequest>* created_request = NULL; | 1072 CComObject<UrlmonUrlRequest>* created_request = NULL; |
1073 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request); | 1073 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request); |
1074 new_request = created_request; | 1074 new_request = created_request; |
1075 } | 1075 } |
1076 | 1076 |
| 1077 // Format upload data if it's chunked. |
| 1078 if (request_info.upload_data && request_info.upload_data->is_chunked()) { |
| 1079 std::vector<net::UploadElement>* elements = |
| 1080 request_info.upload_data->elements_mutable(); |
| 1081 for (size_t i = 0; i < elements->size(); ++i) { |
| 1082 net::UploadElement* element = &(*elements)[i]; |
| 1083 DCHECK(element->type() == net::UploadElement::TYPE_BYTES); |
| 1084 std::string chunk_length = StringPrintf( |
| 1085 "%X\r\n", static_cast<unsigned int>(element->bytes_length())); |
| 1086 std::vector<char> bytes; |
| 1087 bytes.insert(bytes.end(), chunk_length.data(), |
| 1088 chunk_length.data() + chunk_length.length()); |
| 1089 const char* data = element->bytes(); |
| 1090 bytes.insert(bytes.end(), data, data + element->bytes_length()); |
| 1091 const char* crlf = "\r\n"; |
| 1092 bytes.insert(bytes.end(), crlf, crlf + strlen(crlf)); |
| 1093 if (i == elements->size() - 1) { |
| 1094 const char* end_of_data = "0\r\n\r\n"; |
| 1095 bytes.insert(bytes.end(), end_of_data, |
| 1096 end_of_data + strlen(end_of_data)); |
| 1097 } |
| 1098 element->SetToBytes(&bytes[0], static_cast<int>(bytes.size())); |
| 1099 } |
| 1100 } |
| 1101 |
1077 new_request->Initialize(static_cast<PluginUrlRequestDelegate*>(this), | 1102 new_request->Initialize(static_cast<PluginUrlRequestDelegate*>(this), |
1078 request_id, | 1103 request_id, |
1079 request_info.url, | 1104 request_info.url, |
1080 request_info.method, | 1105 request_info.method, |
1081 request_info.referrer, | 1106 request_info.referrer, |
1082 request_info.extra_request_headers, | 1107 request_info.extra_request_headers, |
1083 request_info.upload_data, | 1108 request_info.upload_data, |
1084 static_cast<ResourceType::Type>(request_info.resource_type), | 1109 static_cast<ResourceType::Type>(request_info.resource_type), |
1085 enable_frame_busting_, | 1110 enable_frame_busting_, |
1086 request_info.load_flags); | 1111 request_info.load_flags); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 Stop(); | 1451 Stop(); |
1427 } | 1452 } |
1428 | 1453 |
1429 void UrlmonUrlRequestManager::ResourceFetcherThread::Init() { | 1454 void UrlmonUrlRequestManager::ResourceFetcherThread::Init() { |
1430 CoInitialize(NULL); | 1455 CoInitialize(NULL); |
1431 } | 1456 } |
1432 | 1457 |
1433 void UrlmonUrlRequestManager::ResourceFetcherThread::CleanUp() { | 1458 void UrlmonUrlRequestManager::ResourceFetcherThread::CleanUp() { |
1434 CoUninitialize(); | 1459 CoUninitialize(); |
1435 } | 1460 } |
OLD | NEW |