You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I dont manage to figure out how I get the content of a HTTP response if the status-code is not < 400.
> perl6 -e 'use LibCurl::HTTP; sub MAIN(Str $url) { my $h = LibCurl::HTTP.new; try { $h.GET($url).perform; CATCH{ default {.say}}}; say $h.content }' "www.google.com/fas"
HTTP response code said error
in method perform at /home/martin/.rakudobrew/moar-2017.09/install/share/perl6/site/sources/08E9B748943417E15B3A29F01E431CF45AD845BC (LibCurl::Easy) line 583
in sub MAIN at -e line 1
in block <unit> at -e line 1
> curl -v "www.google.com/fas"
* Trying 172.217.19.68...
* TCP_NODELAY set
* Connected to www.google.com (172.217.19.68) port 80 (#0)
> GET /fas HTTP/1.1
....
< Date: Mon, 29 Jan 2018 16:35:07 GMT
<
<!DOCTYPE html>
<html lang=en>
.... more content....
my real world example is:
I am working with an rest api that returns errors as json as well as having error codes in the http response. i cant figure out how to display those json errors from my api.
The text was updated successfully, but these errors were encountered:
The LibCurl::HTTP convenience methods (GET/HEAD/PUT/etc.) all set :failonerror which throws an exception for any error status-code. You can disable that with setopt(:!failonerror)
perl6 -e 'use LibCurl::HTTP; sub MAIN(Str $url) { my $h = LibCurl::HTTP.new; try { $h.GET($url).setopt(:!failonerror).perform; CATCH{ default {.say}}}; say $h.content }' "www.google.com/fas"
I dont manage to figure out how I get the content of a HTTP response if the status-code is not < 400.
my real world example is:
I am working with an rest api that returns errors as json as well as having error codes in the http response. i cant figure out how to display those json errors from my api.
The text was updated successfully, but these errors were encountered: