allow response status codes with curl

Anonymouse zorael at gmail.com
Thu Oct 3 02:26:47 UTC 2019


On Thursday, 3 October 2019 at 01:02:43 UTC, Hampus wrote:
> I have a program that is using std.curl and right now if a http 
> request returns a status code other than 200 the program will 
> crash like this:
>
> std.net.curl.HTTPStatusException at C:\D\dmd2\windows\bin\..\..\src\phobos\std\net\curl.d(1082): HTTP request returned status code 404 (Not Found)
>
> What I want to do is allow certain stauts codes and I want my 
> program to keep going if it receives for example 404 or 500 but 
> raise an exception for lets say status code 403.
>
> How do I achieve this?

The HTTPStatusException class has a `.status` int member that 
contains the returned status code. Is that what you're looking 
for?

https://dlang.org/library/std/net/curl/http_status_exception.html

Also this thread belongs in the Learn forum.



More information about the Digitalmars-d-announce mailing list