8000 Stop curl from trying to POST stdin (#7098) · temon/arangodb@c7c838e · GitHub < 8000 link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg" data-base-href="https://github.githubassets.com/favicons/favicon">
[go: up one dir, main page]

Skip to content

Commit c7c838e

Browse files
goedderzmchacki
authored andcommitted
Stop curl from trying to POST stdin (arangodb#7098)
* Stop libcurl from trying to POST stdin * Stop relocking every iteration in wait * Restrict setting of empty POSTFIELDS to POST requests * Revert locking change
1 parent 9bb460c commit c7c838e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/SimpleHttpClient/Communicator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,20 @@ void Communicator::createRequestInProgress(NewRequest&& newRequest) {
291291

292292
CURL* handle = handleInProgress->_handle;
293293
struct curl_slist* requestHeaders = nullptr;
294-
if (request->body().length() > 0) {
294+
295+
// CURLOPT_POSTFIELDS has to be set for CURLOPT_POST, even if the body is
296+
// empty.
297+
// Otherwise, curl uses CURLOPT_READFUNCTION on CURLOPT_READDATA, which
298+
// default to fread and stdin, respectively: this can cause curl to wait
299+
// indefinitely.
300+
if (request->body().length() > 0 ||
301+
request->requestType() == RequestType::POST) {
295302
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, request->body().data());
296303
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, request->body().length());
304+
}
297305

306+
// We still omit the content type on empty bodies.
307+
if (request->body().length() > 0) {
298308
switch (request->contentType()) {
299309
case ContentType::UNSET:
300310
case ContentType::CUSTOM:

0 commit comments

Comments
 (0)
0