curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

POST with string body is failing on Windows

From: Michael Ost via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 10 Feb 2022 00:35:06 +0000

Hi,

I've got a C++ library that is using libCurl to communicate with www.google-analytics.com. For the most part, it is working. But in one case it is not. When I POST a string to that site from Windows it responds with 411 - Length required. I've attached libCurl logging output below, and "Content-Length" is being set. I've debugged into the library and found/fixed some things in my library, but I'm still getting this 411 response. When I POST with the same code from the Mac, it works: GA responds with 200.

Other data points:

  * Our libCurl library is old 7.42, but the problem happens with 7.77 as well
  * The same code POSTs successfully on the Mac
  * GET commands work
  * A second site that we POST to is responding with a 400 error, and I was told by the DevOp at that site that the body being sent is empty
  * I fabricated the same command and sent it via curl.exe on the command line, successfully
Any suggestions of what could be going wrong? Or how to debug this further? I'm at a brick wall. Thanks!

/Michael Ost, Avid Technology

Appendix 1:
Here are all of the curl_easy_setopt that we make. You won't necessarily know what the values are, but I thought maybe the setup calls might provide a clue.

  * CURLOPT_ACCEPT_ENCODING, ""
  * CURLOPT_VERBOSE, 1
  * CURLOPT_DEBUGFUNCTION, debug_callback
  * CURLOPT_CONNECTTIMEOUT, cConnectTimeout
  * CURLOPT_NOSIGNAL, 1L
  * CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1
  * CURLOPT_URL, pr->mRequest->mURL.c_str()
  * CURLOPT_POST, 1
  * CURLOPT_POSTFIELDSIZE, upStream.mUploadString.size()
  * CURLOPT_COPYPOSTFIELDS, upStream.mUploadString.c_str()
  * CURLOPT_HTTPHEADER, pr->mHeaders
  * CURLOPT_WRITEFUNCTION, &RstE_Worker::WriteFunction
  * CURLOPT_WRITEDATA, pr
  * CURLOPT_HEADERFUNCTION, &RstE_Worker::HeaderFunction
  * CURLOPT_HEADERDATA, pr
  * CURLOPT_SSL_VERIFYPEER, 1L
  * CURLOPT_SSL_VERIFYHOST, 2L
Appendix 2:
And here is debug logging from the library when the call is made. I added the CURL_DEBUG_CALLBACK(type) strings:

CURL_DEBUG_CALLBACK (info):
Hostname www.google-analytics.com<http://www.google-analytics.com> was found in DNS cache
CURL_DEBUG_CALLBACK (info):
  Trying 216.58.194.206...
CURL_DEBUG_CALLBACK (info):
Connected to www.google-analytics.com<http://www.google-analytics.com> (216.58.194.206) port 443 (#8)
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 1/3)
CURL_DEBUG_CALLBACK (info):
schannel: checking server certificate revocation
CURL_DEBUG_CALLBACK (info):
schannel: sending initial handshake data: sending 185 bytes...
CURL_DEBUG_CALLBACK (info):
schannel: sent initial handshake data: sent 185 bytes
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 2/3)
CURL_DEBUG_CALLBACK (info):
schannel: failed to receive handshake, need more data
RstE_Worker::ThreadMethod - calling curl_multi_performCURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 2/3)
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 4096 length 4096
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data length: 4028
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 4028 length 4096
CURL_DEBUG_CALLBACK (info):
schannel: received incomplete message, need more data
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 2/3)
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 4391 length 5052
CURL_DEBUG_CALLBACK (info):
schannel: sending next handshake data: sending 93 bytes...
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 2/3)
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 292 length 5052
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS handshake complete
CURL_DEBUG_CALLBACK (info):
schannel: SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443 (step 3/3)
CURL_DEBUG_CALLBACK (info):
schannel: incremented credential handle refcount = 1
CURL_DEBUG_CALLBACK (info):
schannel: stored credential handle in session cache
CURL_DEBUG_CALLBACK (=> Send header):
POST /batch HTTP/1.1
Host: www.google-analytics.com<http://www.google-analytics.com>
Accept: */*
Accept-Encoding: identity
Authorization: Bearer MDA***********************

User-Agent: avid-ptc-google-analytics
Content-type: text/plain
Content-Length: 522

CURL_DEBUG_CALLBACK (=> Send data):
v=1&ds=app&tid=UA-85021764-2&an=protools_unit_test&av=x.y.z&ua=AvidProTools%2f12.X%20(Windows%20NT%201.2%3b%20Win64%3b%20x64)&ul=zh-CN&cid=b5543933-084c-a54b-8b90-a515dd86a4c4&t=event&ec=jawhol&ea=sargeantSchultz&el=deutsch&ev=999&cd=protools_unit_test&z=984363590
v=1&ds=app&tid=UA-85021764-2&an=protools_unit_test&av=x.y.z&ua=AvidProTools%2f12.X%20(Windows%20NT%201.2%3b%20Win64%3b%20x64)&ul=zh-CN&cid=b5543933-084c-a54b-8b90-a515dd86a4c4&t=event&ec=jawhol&ea=colonelHogan&el=gi&ev=777&cd=protools_unit_test&z=311506490
CURL_DEBUG_CALLBACK (info):
upload completely sent off: 522 out of 522 bytes
CURL_DEBUG_CALLBACK (info):
schannel: client wants to read 16384 bytes
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 0 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data got 1783
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data buffer: offset 1783 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data length: 1401
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data added: 1401
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data cached: offset 1401 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data length: 353
CURL_DEBUG_CALLBACK (info):
schannel: encrypted data cached: offset 353 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data length: 324
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data added: 324
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data cached: offset 1725 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data buffer: offset 1725 length 16384
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data returned 1725
CURL_DEBUG_CALLBACK (info):
schannel: decrypted data buffer: offset 0 length 16384
CURL_DEBUG_CALLBACK (info):
HTTP 1.0, assume close after body
CURL_DEBUG_CALLBACK (<= Recv header):
HTTP/1.0 411 Length Required
CURL_DEBUG_CALLBACK (<= Recv header):
Content-Type: text/html; charset=UTF-8
CURL_DEBUG_CALLBACK (<= Recv header):
Referrer-Policy: no-referrer
CURL_DEBUG_CALLBACK (<= Recv header):
Content-Length: 1564
CURL_DEBUG_CALLBACK (<= Recv header):
Date: Wed, 09 Feb 2022 23:41:30 GMT
CURL_DEBUG_CALLBACK (<= Recv header):

CURL_DEBUG_CALLBACK (<= Recv data):
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 411 (Length Required)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png<http://www.google.com/images/errors/robot.png>) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}_at_media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png<http://www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png>) no-repeat;margin-left:-5px}_at_media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png<http://www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png>) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png<http://www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png>) 0}}_at_media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png<http://www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png>) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/<http://www.google.com/>><span id=logo aria-label=Google></span></a>
  <p><b>411.</b> <ins>ThatΓÇÖs an error.</ins>
  <p>POST requests require a <code>Content-length</code> header. <ins>ThatΓÇÖs all we know.</ins>
CURL_DEBUG_CALLBACK (info):
Closing connection 8
CURL_DEBUG_CALLBACK (info):
schannel: shutting down SSL/TLS connection with www.google-analytics.com<http://www.google-analytics.com> port 443
CURL_DEBUG_CALLBACK (info):
schannel: clear security context handle
CURL_DEBUG_CALLBACK (info):
schannel: decremented credential handle refcount = 0


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-02-10