Represents a client-side HTTP request.
Instances are created by an HttpClient
instance, via one of the methods corresponding to the
specific HTTP methods, or the generic request
method. Once a request has been obtained, headers can be set on
it, and data can be written to its body if required. Once you are ready to send the request, the end()
method
should be called.
Nothing is actually sent until the request has been internally assigned an HTTP connection. The HttpClient
instance will return an instance of this class immediately, even if there are no HTTP connections available
in the pool. Any requests sent before a connection is assigned will be queued internally and actually sent
when an HTTP connection becomes available from the pool.
The headers of the request are actually sent either when the end()
method is called, or, when the first
part of the body is written, whichever occurs first.
This class supports both chunked and non-chunked HTTP.
An example of using this class is as follows:
HttpClientRequest req = client. request(post, "/some-url"). headers { "some-header"->"hello", "Content-Length"->"5" }; req.response.onComplete((HttpClientResponse resp) => print("Got response ``resp.status``")); req.end("hello");
Instances of HttpClientRequest are not thread-safe.
Anything
HttpClientRequest
HttpOutput
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
HttpClientRequest(HttpClient delegate, String method, String uri) |
Attributes | |
chunked | shared actual Boolean chunked Is the request chunked? Refines HttpOutput.chunked |
response | shared Promise<HttpClientResponse> response The response promise is resolved when the http client response is available. todo: consider provide an handler instead of having a Promise |
stream | shared actual WriteStream stream The write stream of this request Refines HttpOutput.stream |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
end | shared actual HttpClientRequest end(Chunk? chunk) Ends the response. If no data has been written to the response body, the actual response won't get written until this method gets called. Once the response has ended, it cannot be used any more. Refines HttpOutput.end |
headers | shared actual HttpClientRequest headers(Entries headers) Set the response headers. Refines HttpOutput.headers |
timeout | shared HttpClientRequest timeout(Integer t) Set's the amount of time after which if a response is not received Parameters:
|
write | shared actual HttpClientRequest write(Chunk chunk) Write a chunk to the output body. Refines HttpOutput.write |
Inherited Methods |
Methods inherited from: HttpOutput<O> |
Methods inherited from: Object equals |