// callback for client reader void sink (char[] content) { Stdout.put (content); } // create client for a GET request auto HttpClient client = new HttpClient (HttpClient.Get, "http://www.digitalmars.com/d/intro.html"); // setup a Host header client.getRequestHeaders.add (HttpHeader.Host, client.getUri.getHost()); // make request client.open (); // check return status for validity if (client.isResponseOK) { // extract content length (be aware of -1 return, for no header) int length = client.getResponseHeaders.getInt (HttpHeader.ContentLength); if (length < 0) length = int.max; // display all returned headers Stdout.put (client.getResponseHeaders); // display remaining content client.read (&sink, length); } else Stderr.put (client.getResponse);
Definition at line 96 of file HttpClient.d.
|
Attempt to clean up when garbage collected Definition at line 176 of file HttpClient.d. References close(). |
|
Create a client for the given URL. The argument should be fully qualified with an "http:" or "https:" scheme, or an explicit port should be provided. Definition at line 141 of file HttpClient.d. References method. |
|
Create a client with the provided Uri instance. The Uri should be fully qualified with an "http:" or "https:" scheme, or an explicit port should be provided. Definition at line 154 of file HttpClient.d. References Buffer, cookiesOut, Uri::getHost(), Uri::getValidPort(), headersIn, headersOut, HttpHeaders, method, paramsOut, responseLine, and uri. |
|
Get the current input headers, as returned by the host request. Definition at line 187 of file HttpClient.d. References headersIn. Referenced by testHttpClient3(). |
|
Gain access to the request headers. Use this to add whatever headers are required for a request. Definition at line 199 of file HttpClient.d. References headersOut. Referenced by testHttpClient3(). |
|
Gain access to the request parameters. Use this to add x=y style parameters to the request. These will be appended to the request assuming the original Uri does not contain any of its own. Definition at line 213 of file HttpClient.d. References paramsOut. |
|
Return the Uri associated with this client Definition at line 224 of file HttpClient.d. References uri. Referenced by testHttpClient3(). |
|
Return the response-line for the latest request. This takes the form of "version status reason" as defined in the HTTP RFC. Definition at line 237 of file HttpClient.d. References responseLine. |
|
Return the HTTP status code set by the remote server Definition at line 248 of file HttpClient.d. References ResponseLine::getStatus(), and responseLine. Referenced by isResponseOK(). |
|
Return whether the response was OK or not Definition at line 259 of file HttpClient.d. References getStatus(), and HttpResponseCode. Referenced by testHttpClient3(). |
|
Add a cookie to the outgoing headers Definition at line 270 of file HttpClient.d. References HttpMutableCookies::add(), and cookiesOut. |
|
Close all resources used by a request. You must invoke this between successive open() calls. Definition at line 282 of file HttpClient.d. References IResource::close(), Socket::shutdown(), and socket. Referenced by ~this(). |
|
Reset the client such that it is ready for a new request. Definition at line 298 of file HttpClient.d. References headersIn, headersOut, paramsOut, and HttpTokens::reset(). |
|
Overridable method to create a Socket. You may find a need to override this for some purpose; perhaps to add input or output filters. Definition at line 313 of file HttpClient.d. |
|
Make a request for the resource specified via the constructor, using a callback for pumping additional data to the host. This defaults to a three-second timeout period. The return value represents the input buffer, from which all returned headers and content may be accessed. Definition at line 328 of file HttpClient.d. References DefaultReadTimeout. Referenced by open(), and testHttpClient3(). |
|
Make a request for the resource specified via the constructor, using the specified timeout period (in milli-seconds).The return value represents the input buffer, from which all returned headers and content may be accessed. Definition at line 342 of file HttpClient.d. References open(). |
|
Make a request for the resource specified via the constructor using the specified timeout period (in micro-seconds), and a user-defined callback for pumping additional data to the host. The callback would be used when uploading data during a 'put' operation (or equivalent). The return value represents the input buffer, from which all returned headers and content may be accessed. Definition at line 359 of file HttpClient.d. References Socket::connect(), IWriter::cr(), SocketConduit::createBuffer(), DefaultHttpVersion, DisplayWriter, IWriter::flush(), Uri::getPath(), headersIn, headersOut, input, method, HttpClient::RequestMethod::name, CompositeToken::next(), output, paramsOut, HttpHeaders::parse, ResponseLine::parse(), IWriter::put(), IBuffer::readable(), responseLine, MutableUri::setQuery(), SocketConduit::setTimeout(), socket, uri, and IWritable::write(). |
|
Definition at line 420 of file HttpClient.d. References IBuffer::clear(), IConduit::Eof, input, SocketConduit::read(), IBuffer::readable(), socket, and IBuffer::toString(). Referenced by testHttpClient3(). |
|
Definition at line 105 of file HttpClient.d. |
|
Definition at line 106 of file HttpClient.d. |
|
Definition at line 106 of file HttpClient.d. Referenced by open(). |
|
Definition at line 108 of file HttpClient.d. |
|
Definition at line 109 of file HttpClient.d. |
|
Definition at line 110 of file HttpClient.d. |
|
Definition at line 111 of file HttpClient.d. Referenced by getRequestParams(), open(), reset(), and this(). |
|
Definition at line 112 of file HttpClient.d. Referenced by getResponseHeaders(), open(), reset(), and this(). |
|
Definition at line 113 of file HttpClient.d. Referenced by getRequestHeaders(), open(), reset(), and this(). |
|
Definition at line 114 of file HttpClient.d. Referenced by addCookie(), and this(). |
|
Definition at line 115 of file HttpClient.d. Referenced by getResponse(), getStatus(), open(), and this(). |
|
Definition at line 118 of file HttpClient.d. Referenced by open(). |
|
Definition at line 121 of file HttpClient.d. Referenced by open(). |
|
Definition at line 124 of file HttpClient.d. |
|
Definition at line 125 of file HttpClient.d. |
|
Definition at line 126 of file HttpClient.d. |
|
Definition at line 127 of file HttpClient.d. |
|
Definition at line 128 of file HttpClient.d. |
|
Definition at line 129 of file HttpClient.d. |
|
Definition at line 130 of file HttpClient.d. |
|
Definition at line 131 of file HttpClient.d. |