Dart API Referencedart:ioHttpClient

HttpClient Interface

HTTP client factory. The HttpClient handles all the sockets associated with the HttpClientConnections and when the endpoint supports it, it will try to reuse opened sockets for several requests to support HTTP 1.1 persistent connections. This means that sockets will be kept open for some time after a requests have completed, unless HTTP procedures indicate that it must be closed as part of completing the request. Use HttpClient.shutdown to force close the idle sockets.

Constructors

Code new HttpClient() #

HttpClient();

Static Fields

Code final int DEFAULT_HTTP_PORT #

static final int DEFAULT_HTTP_PORT = 80;

Methods

Code HttpClientConnection get(String host, int port, String path) #

Opens a HTTP connection using the GET method. See open for details. Using this method to open a HTTP connection will set the content length to 0.

HttpClientConnection get(String host, int port, String path);

Code HttpClientConnection getUrl(Uri url) #

Opens a HTTP connection using the GET method. See openUrl for details. Using this method to open a HTTP connection will set the content length to 0.

HttpClientConnection getUrl(Uri url);

Code HttpClientConnection open(String method, String host, int port, String path) #

Opens a HTTP connection. The returned HttpClientConnection is used to register callbacks for asynchronous events on the HTTP connection. The "Host" header for the request will be set to the value host: port. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if host is an IP address this will still be set in the "Host" header.

HttpClientConnection open(String method, String host, int port, String path);

Code HttpClientConnection openUrl(String method, Uri url) #

Opens a HTTP connection. The returned HttpClientConnection is used to register callbacks for asynchronous events on the HTTP connection. The "Host" header for the request will be set based the host and port specified in url. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if the host is specified as an IP address this will still be set in the "Host" header.

HttpClientConnection openUrl(String method, Uri url);

Code HttpClientConnection post(String host, int port, String path) #

Opens a HTTP connection using the POST method. See open for details.

HttpClientConnection post(String host, int port, String path);

Code HttpClientConnection postUrl(Uri url) #

Opens a HTTP connection using the POST method. See openUrl for details.

HttpClientConnection postUrl(Uri url);

Code void shutdown() #

Shutdown the HTTP client releasing all resources.

void shutdown();