How to do HEAD request in std.net.curl
data pulverizer
data.pulverizer at gmail.com
Sun Apr 26 22:14:33 UTC 2020
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();
}
```
More information about the Digitalmars-d-learn
mailing list