April 26, 2020 How to do HEAD request in std.net.curl | ||||
---|---|---|---|---|
| ||||
Hi all, I am using std.net.curl and would like to run a HEAD request to find out if a web page exists - I've looked at the documentation and have tried various things that haven't worked. Thanks |
April 26, 2020 Re: How to do HEAD request in std.net.curl | ||||
---|---|---|---|---|
| ||||
Posted in reply to data pulverizer | On Sunday, 26 April 2020 at 22:03:33 UTC, data pulverizer wrote: > Hi all, > > I am using std.net.curl and would like to run a HEAD request to find out if a web page exists - I've looked at the documentation and have tried various things that haven't worked. > > Thanks Never mind, I've got it, the answer was in a previous issue: https://forum.dlang.org/post/mailman.301.1412409956.9932.digitalmars-d-bugs@puremagic.com ``` import std.net.curl; void main() { auto http = HTTP("dlang.org/non-existing-url"); http.onReceiveStatusLine = (HTTP.StatusLine s) { if (s.code != 200) throw new Exception("Request failed."); }; http.method = HTTP.Method.head; http.perform(); } ``` |
Copyright © 1999-2021 by the D Language Foundation