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 DCHECK(url_components.nScheme == INTERNET_SCHEME_HTTP || |
| 123 url_components.nScheme == INTERNET_SCHEME_HTTPS); |
122 std::wstring host_name(url_components.lpszHostName, | 124 std::wstring host_name(url_components.lpszHostName, |
123 url_components.dwHostNameLength); | 125 url_components.dwHostNameLength); |
124 std::wstring url_path(url_components.lpszUrlPath, | 126 std::wstring url_path(url_components.lpszUrlPath, |
125 url_components.dwUrlPathLength); | 127 url_components.dwUrlPathLength); |
126 std::wstring extra_info(url_components.lpszExtraInfo, | 128 std::wstring extra_info(url_components.lpszExtraInfo, |
127 url_components.dwExtraInfoLength); | 129 url_components.dwExtraInfoLength); |
128 | 130 |
129 ScopedHINTERNET connect(WinHttpConnect( | 131 ScopedHINTERNET connect(WinHttpConnect( |
130 session.get(), host_name.c_str(), url_components.nPort, 0)); | 132 session.get(), host_name.c_str(), url_components.nPort, 0)); |
131 if (!connect.get()) { | 133 if (!connect.get()) { |
132 LogErrorWinHttpMessage("WinHttpConnect"); | 134 LogErrorWinHttpMessage("WinHttpConnect"); |
133 return false; | 135 return false; |
134 } | 136 } |
135 | 137 |
136 ScopedHINTERNET request( | 138 ScopedHINTERNET request(WinHttpOpenRequest( |
137 WinHttpOpenRequest(connect.get(), | 139 connect.get(), |
138 base::UTF8ToUTF16(method()).c_str(), | 140 base::UTF8ToUTF16(method()).c_str(), |
139 url_path.c_str(), | 141 url_path.c_str(), |
140 nullptr, | 142 nullptr, |
141 WINHTTP_NO_REFERER, | 143 WINHTTP_NO_REFERER, |
142 WINHTTP_DEFAULT_ACCEPT_TYPES, | 144 WINHTTP_DEFAULT_ACCEPT_TYPES, |
143 0)); | 145 url_components.nScheme == INTERNET_SCHEME_HTTPS ? WINHTTP_FLAG_SECURE |
| 146 : 0)); |
144 if (!request.get()) { | 147 if (!request.get()) { |
145 LogErrorWinHttpMessage("WinHttpOpenRequest"); | 148 LogErrorWinHttpMessage("WinHttpOpenRequest"); |
146 return false; | 149 return false; |
147 } | 150 } |
148 | 151 |
149 // Add headers to the request. | 152 // Add headers to the request. |
150 for (const auto& pair : headers()) { | 153 for (const auto& pair : headers()) { |
151 std::wstring header_string = | 154 std::wstring header_string = |
152 base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second); | 155 base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second); |
153 if (!WinHttpAddRequestHeaders( | 156 if (!WinHttpAddRequestHeaders( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 238 } |
236 | 239 |
237 } // namespace | 240 } // namespace |
238 | 241 |
239 // static | 242 // static |
240 scoped_ptr<HTTPTransport> HTTPTransport::Create() { | 243 scoped_ptr<HTTPTransport> HTTPTransport::Create() { |
241 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); | 244 return scoped_ptr<HTTPTransportWin>(new HTTPTransportWin); |
242 } | 245 } |
243 | 246 |
244 } // namespace crashpad | 247 } // namespace crashpad |
OLD | NEW |