curl / Mailing Lists / curl-users / 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.

cURL Content-Length problem

From: Arthur Azevedo via curl-users <curl-users_at_cool.haxx.se>
Date: Thu, 28 May 2020 12:09:51 -0300

Hi

I´m new to cURL, and I´m trying to use it in PowerShell scripts to test my
company´s products APIs/web-services.

But I having problem with the response body when the text contains accents
(or should I say diacritical marks? what´s the correct?). I believe the
Content-Length is counting letters, not bytes. I´m receiving the response -
a json, without the close curly brace at the final.

I already tried --ignore-content-length, but with HTTP the cURL keeps
waiting for and end connection that never came and exit with timeout error.

Why not use Invoke-WebRequest? I need the response header,
the Invoke-WebRequest intercepts HTTP errors, I need to use old versions of
Powershell, on Windows and Linux, etc, etc, etc

using cURL with -v I get:

PS E:\SVN_REP\topinstalador\trunk\Instalador_Web> curl.exe --location
--silent --show-error --header 'Content-Type: application/json' `
>> --header 'Authorization: Bearer ******************' `
>> --insecure --include --raw `
>> --data-binary '{ \"arquivoAnexoBytes\":
\"QXJxdWl2byB0ZXN0ZSBkZSAyMDIwMDUyODEwMjk0Mi50eHQ=\", \"nomeArquivox\":
\"Arquivo teste de 20200528102942.txt\", \"descricao\": \"Teste de Upload
para operacao\", \"destino\": \"WEB_FILE_FATURA\", \"modulo\":
\"4\",\"codfuncao\": \"teste\",\"txtIp\": \"\"}' `
>> -POST --url "
http://223.223.2.236/APIs/UploadService/api/transferencia/upload" -v
--header 'Accept: charset=charset=ISO-8859-1'
* Trying 223.223.2.236...
* TCP_NODELAY set
* Connected to 223.223.2.236 (223.223.2.236) port 80 (#0)
> POST /APIs/UploadService/api/transferencia/upload HTTP/1.1
> Host: 223.223.2.236
> User-Agent: curl/7.55.1
> Content-Type: application/json
> Authorization: Bearer ***********
> Accept: charset=charset=ISO-8859-1
> Content-Length: 258
>
* upload completely sent off: 258 out of 258 bytes
< HTTP/1.1 400 Bad Request
< Content-Length: 55
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/8.0
< X-Powered-By: ASP.NET
< Date: Thu, 28 May 2020 14:12:55 GMT
<
* Excess found in a non pipelined read: excess = 1, size = 55, maxdownload
= 55, bytecount = 0
{"NomeArquivo":["O nome do arquivo não foi informado"]* Connection #0 to
host 223.223.2.236 left intact

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-05-28