www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to do HEAD request in std.net.curl

reply data pulverizer <data.pulverizer gmail.com> writes:
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
Apr 26 2020
parent data pulverizer <data.pulverizer gmail.com> writes:
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(); } ```
Apr 26 2020