Ensure request buffer is available for WinHTTP.
Bug: 1383611 Change-Id: I5bd138a8b2e0c80de686f655e93bbfe254e3b1a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4024532 Auto-Submit: Xiaoling Bao <xiaolingbao@chromium.org> Reviewed-by: Sorin Jianu <sorin@chromium.org> Commit-Queue: Sorin Jianu <sorin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1070627}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b2a4b6f53b
commit
3d98e1682f
components/winhttp
@@ -267,9 +267,14 @@ HRESULT NetworkFetcher::SendRequest(const std::string& data) {
|
||||
|
||||
VLOG(2) << data;
|
||||
|
||||
const uint32_t bytes_to_send = base::saturated_cast<uint32_t>(data.size());
|
||||
void* request_body =
|
||||
bytes_to_send ? const_cast<char*>(data.c_str()) : WINHTTP_NO_REQUEST_DATA;
|
||||
// Make a copy of the request data to ensure the buffer is available until
|
||||
// the request is processed.
|
||||
request_data_ = data;
|
||||
|
||||
const uint32_t bytes_to_send =
|
||||
base::saturated_cast<uint32_t>(request_data_.size());
|
||||
void* request_body = bytes_to_send ? const_cast<char*>(request_data_.c_str())
|
||||
: WINHTTP_NO_REQUEST_DATA;
|
||||
if (!::WinHttpSendRequest(request_handle_.get(),
|
||||
WINHTTP_NO_ADDITIONAL_HEADERS, 0, request_body,
|
||||
bytes_to_send, bytes_to_send, context())) {
|
||||
|
@@ -133,6 +133,7 @@ class NetworkFetcher : public base::RefCountedThreadSafe<NetworkFetcher> {
|
||||
std::string path_for_request_;
|
||||
|
||||
base::WStringPiece verb_;
|
||||
std::string request_data_;
|
||||
// The value of Content-Type header, e.g. "application/json".
|
||||
std::string content_type_;
|
||||
WriteDataCallback write_data_callback_;
|
||||
|
Reference in New Issue
Block a user