Creates a multipart/form-data object that is suitable for file uploads and other kinds of POST.
An experimental component for working with REST apis. Note that it is a zero-argument template, so to create one, use new HttpApiClient!()(args..) or you will get "HttpApiClient is used as a type" compile errors.
HttpClient keeps cookies, location, and some other state to reuse connections, when possible, like a web browser. You can use it as your entry point to make http requests.
A pseudo-cache to provide a mock server. Construct one of these, populate it with test responses, and pass it to HttpClient to do a network-free test.
Represents a HTTP request. You usually create these through a HttpClient.
WebSocket client, based on the browser api, though also with other api options.
Supported file formats for HttpClient.setClientCert. These are loaded by OpenSSL in the current implementation.
auto request = get("http://arsdnet.net/"); request.send();
gets the text off a url. basic operation only.
Do not forget to call waitForCompletion() on the returned object!
Waits for the first of the given requests to be either aborted or completed. Returns the first one in that state, or null if the operation was interrupted or reached the given timeout before any completed. (If it returns null even before the timeout, it might be because the user pressed ctrl+c, so you should consider checking if you should cancel the operation. If not, you can simply call it again with the same arguments to start waiting again.)
An input range that runs waitForFirstToComplete but only returning each request once. Before you loop over it, you can set some properties to customize behavior.
Represents a URI. It offers named access to the components and relative uri resolution, though as a user of the library, you'd mostly just construct it like Uri("http://example.com/index.html").
Warning: you should call this AFTER websocket.connect or else it might throw on connect because the function sets nonblocking mode and the connect function doesn't handle that well (it throws on the "would block" condition in that function. easier to just do that first)
It has no dependencies for basic operation, but does require OpenSSL libraries (or compatible) to support HTTPS. This dynamically loaded on-demand (meaning it won't be loaded if you don't use it, but if you do use it, the openssl dynamic libraries must be found in the system search path).
On Windows, you can bundle the openssl dlls with your exe and they will be picked up when distributed.
You can compile with -version=without_openssl to entirely disable ssl support.
http2.d, despite its name, does NOT implement HTTP/2.0, but this shouldn't matter for 99.9% of usage, since all servers will continue to support HTTP/1.1 for a very long time.
import arsd.http2; void main() { auto client = new HttpClient(); auto request = client.request(Uri("http://dlang.org/")); auto response = request.waitForCompletion(); import std.stdio; writeln(response.contentText); writeln(response.code, " ", response.codeText); writeln(response.contentType); }
Automatic 100 Continue handling was added on September 28, 2021. It doesn't set the Expect header, so it isn't supposed to happen, but plenty of web servers don't follow the standard anyway.
A dependency on arsd.core was added on March 19, 2023 (dub v11.0). Previously, module was stand-alone. You will have add the core.d file from the arsd repo to your build now if you are managing the files and builds yourself.
The benefits of this dependency include some simplified implementation code which makes it easier for me to add more api conveniences, better exceptions with more information, and better event loop integration with other arsd modules beyond just the simpledisplay adapters available previously. The new integration can also make things like heartbeat timers easier for you to code.
This is version 2 of my http/1.1 client implementation.