On Friday, 14 February 2020 at 13:23:01 UTC, Andre Pany wrote:
On Friday, 14 February 2020 at 00:24:27 UTC, Gregor Mückl wrote:
Hi!

I am trying to write a client for pretty... well... creatively designed web API. The server gives HTTP status 500 replies if the requests are malformed, but the actual error message is hidden in the body of the reply (an XML document!). std.net.curl.get() throws an exception in this case. But I would like to get the body to process the error message within. How can I do that?

Thanks in advance,
Gregor

Hi Gregor,

If I am not completely wrong, the exception has an attribute
"msg" which should contain the body of the http response.

Kind regards
André

Unfortunately, this is not true. The msg only contains the text information in the status line of the HTTP reply. If I'm not mistaken, the exception is created in this line in std/net/curl.d:

enforce(statusLine.code / 100 == 2, new HTTPStatusException(statusLine.code, format("HTTP request returned status code %d (%s)", statusLine.code, statusLine.reason)));

If anything is wrong, the server I'm interested in tends to reply with a status code 500 and a generic status line text and a bloated XML body containing the actual error message.

Reply via email to