Chromium Code Reviews| 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, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 url_components.dwStructSize = sizeof(URL_COMPONENTS); | 112 url_components.dwStructSize = sizeof(URL_COMPONENTS); |
| 113 url_components.dwHostNameLength = 1; | 113 url_components.dwHostNameLength = 1; |
| 114 url_components.dwUrlPathLength = 1; | 114 url_components.dwUrlPathLength = 1; |
| 115 url_components.dwExtraInfoLength = 1; | 115 url_components.dwExtraInfoLength = 1; |
| 116 std::wstring url_wide(base::UTF8ToUTF16(url())); | 116 std::wstring url_wide(base::UTF8ToUTF16(url())); |
| 117 if (!WinHttpCrackUrl( | 117 if (!WinHttpCrackUrl( |
| 118 url_wide.c_str(), 0, ICU_REJECT_USERPWD, &url_components)) { | 118 url_wide.c_str(), 0, ICU_REJECT_USERPWD, &url_components)) { |
| 119 LogErrorWinHttpMessage("WinHttpCrackUrl"); | 119 LogErrorWinHttpMessage("WinHttpCrackUrl"); |
| 120 return false; | 120 return false; |
| 121 } | 121 } |
| 122 std::wstring host_name(url_components.lpszHostName, | 122 std::wstring host_name(url_components.lpszHostName, |
|
Mark Mentovai
2015/08/26 22:17:38
DCHECK that nScheme is INTERNET_SCHEME_HTTP or INT
scottmg
2015/08/31 20:28:31
Done.
| |
| 123 url_components.dwHostNameLength); | 123 url_components.dwHostNameLength); |
| 124 std::wstring url_path(url_components.lpszUrlPath, | 124 std::wstring url_path(url_components.lpszUrlPath, |
| 125 url_components.dwUrlPathLength); | 125 url_components.dwUrlPathLength); |
| 126 std::wstring extra_info(url_components.lpszExtraInfo, | 126 std::wstring extra_info(url_components.lpszExtraInfo, |
| 127 url_components.dwExtraInfoLength); | 127 url_components.dwExtraInfoLength); |
| 128 | 128 |
| 129 ScopedHINTERNET connect(WinHttpConnect( | 129 ScopedHINTERNET connect(WinHttpConnect( |
| 130 session.get(), host_name.c_str(), url_components.nPort, 0)); | 130 session.get(), host_name.c_str(), url_components.nPort, 0)); |
| 131 if (!connect.get()) { | 131 if (!connect.get()) { |
| 132 LogErrorWinHttpMessage("WinHttpConnect"); | 132 LogErrorWinHttpMessage("WinHttpConnect"); |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 | 135 |
| 136 ScopedHINTERNET request( | 136 ScopedHINTERNET request(WinHttpOpenRequest( |
| 137 WinHttpOpenRequest(connect.get(), | 137 connect.get(), |
| 138 base::UTF8ToUTF16(method()).c_str(), | 138 base::UTF8ToUTF16(method()).c_str(), |
| 139 url_path.c_str(), | 139 url_path.c_str(), |
| 140 nullptr, | 140 nullptr, |
| 141 WINHTTP_NO_REFERER, | 141 WINHTTP_NO_REFERER, |
| 142 WINHTTP_DEFAULT_ACCEPT_TYPES, | 142 WINHTTP_DEFAULT_ACCEPT_TYPES, |
| 143 0)); | 143 url_components.nScheme == INTERNET_SCHEME_HTTPS ? WINHTTP_FLAG_SECURE |
| 144 : 0)); | |
| 144 if (!request.get()) { | 145 if (!request.get()) { |
| 145 LogErrorWinHttpMessage("WinHttpOpenRequest"); | 146 LogErrorWinHttpMessage("WinHttpOpenRequest"); |
| 146 return false; | 147 return false; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // Add headers to the request. | 150 // Add headers to the request. |
| 150 for (const auto& pair : headers()) { | 151 for (const auto& pair : headers()) { |
| 151 std::wstring header_string = | 152 std::wstring header_string = |
| 152 base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second); | 153 base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second); |
| 153 if (!WinHttpAddRequestHeaders( | 154 if (!WinHttpAddRequestHeaders( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 } | 236 } |
| 236 | 237 |
| 237 } // namespace | 238 } // namespace |
| 238 | 239 |
| 239 // static | 240 // static |
| 240 scoped_ptr<HTTPTransport> HTTPTransport::Create() { | 241 scoped_ptr<HTTPTransport> HTTPTransport::Create() { |
| 241 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); | 242 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); |
| 242 } | 243 } |
| 243 | 244 |
| 244 } // namespace crashpad | 245 } // namespace crashpad |
| OLD | NEW |