OLD | NEW |
---|---|
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/net/http_transport.h" | 15 #include "util/net/http_transport.h" |
16 | 16 |
17 #include <windows.h> | 17 #include <windows.h> |
18 #include <winhttp.h> | 18 #include <winhttp.h> |
19 | 19 |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/numerics/safe_conversions.h" | 21 #include "base/numerics/safe_conversions.h" |
22 #include "base/scoped_generic.h" | 22 #include "base/scoped_generic.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "util/net/http_body.h" | 25 #include "util/net/http_body.h" |
26 #include "package.h" | 26 #include "package.h" |
Mark Mentovai
2015/10/22 22:56:18
Sort
scottmg
2015/10/22 23:13:40
Done.
| |
27 | 27 |
28 namespace crashpad { | 28 namespace crashpad { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // PLOG doesn't work for messages from WinHTTP, so we need to use | 32 // PLOG doesn't work for messages from WinHTTP, so we need to use |
33 // FORMAT_MESSAGE_FROM_HMODULE + the dll name manually here. | 33 // FORMAT_MESSAGE_FROM_HMODULE + the dll name manually here. |
34 void LogErrorWinHttpMessage(const char* extra) { | 34 void LogErrorWinHttpMessage(const char* extra) { |
35 DWORD error_code = GetLastError(); | 35 DWORD error_code = GetLastError(); |
36 char msgbuf[256]; | 36 char msgbuf[256]; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 | 167 |
168 // We need the Content-Length up front, so buffer in memory. We should modify | 168 // We need the Content-Length up front, so buffer in memory. We should modify |
169 // the interface to not require this, and then use WinHttpWriteData after | 169 // the interface to not require this, and then use WinHttpWriteData after |
170 // WinHttpSendRequest. | 170 // WinHttpSendRequest. |
171 std::vector<uint8_t> post_data; | 171 std::vector<uint8_t> post_data; |
172 | 172 |
173 // Write the body of a POST if any. | 173 // Write the body of a POST if any. |
174 const size_t kBufferSize = 4096; | 174 const size_t kBufferSize = 4096; |
175 for (;;) { | 175 for (;;) { |
176 uint8_t buffer[kBufferSize]; | 176 uint8_t buffer[kBufferSize]; |
177 ssize_t bytes_to_write = | 177 FileOperationResult bytes_to_write = |
Mark Mentovai
2015/10/22 22:56:18
file_io.h
scottmg
2015/10/22 23:13:40
Done.
| |
178 body_stream()->GetBytesBuffer(buffer, sizeof(buffer)); | 178 body_stream()->GetBytesBuffer(buffer, sizeof(buffer)); |
179 if (bytes_to_write == 0) | 179 if (bytes_to_write == 0) |
180 break; | 180 break; |
181 post_data.insert(post_data.end(), buffer, buffer + bytes_to_write); | 181 post_data.insert(post_data.end(), buffer, buffer + bytes_to_write); |
182 } | 182 } |
183 | 183 |
184 if (!WinHttpSendRequest(request.get(), | 184 if (!WinHttpSendRequest(request.get(), |
185 WINHTTP_NO_ADDITIONAL_HEADERS, | 185 WINHTTP_NO_ADDITIONAL_HEADERS, |
186 0, | 186 0, |
187 &post_data[0], | 187 &post_data[0], |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 } | 240 } |
241 | 241 |
242 } // namespace | 242 } // namespace |
243 | 243 |
244 // static | 244 // static |
245 scoped_ptr<HTTPTransport> HTTPTransport::Create() { | 245 scoped_ptr<HTTPTransport> HTTPTransport::Create() { |
246 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); | 246 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); |
247 } | 247 } |
248 | 248 |
249 } // namespace crashpad | 249 } // namespace crashpad |
OLD | NEW |