POST request with std.net.curl

frame frame86 at live.com
Mon Jul 26 19:53:05 UTC 2021


On Monday, 26 July 2021 at 14:13:53 UTC, bachmeier wrote:

>> In doubt you can turn on the verbose() method on the HTTP 
>> object.
>
> That's a modest improvement (for the small number of people 
> that find the option in the docs) but definitely not at the 
> same level of information as the curl CLI. I created an issue 
> requesting better output: 
> <https://issues.dlang.org/show_bug.cgi?id=22142>

I see your intention but this is a bad example. Status 400 means 
"Bad request" because of a wrong header or wrong payload or any 
error in the request. "Empty content" wouldn't describe the 
actual error if you have sent data.

In fact the client cannot know whats wrong. "Content-Type: 
Application/json" may be wrong from the sight of the server 
(which is NOT, they are case insensitive btw) but the protocol 
allows you to use whatever content-type you want and no client 
needs to know how to handle all. It's just wrong if your CLI tool 
interprets a status 400 as "Empty content" by arbitrary 
assumptions.

All better the lib could do is to print the text for the status 
too and the raw payload sent by the server aka error description, 
if any.


More information about the Digitalmars-d-learn mailing list