Class HttpClientRequest
source code
object --+
|
streams.WriteStream --+
|
HttpClientRequest
Instances of this class are created by an HttpClient instance, via one
of the methods corresponding to the specific HTTP methods, or the generic
HttpClient request method.
Once an instance of this class 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 must called.
Nothing is 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.
- Overrides:
object.__init__
- (inherited documentation)
|
Hash of headers for the request
- Decorators:
|
Inserts a header into the request.
Keyword arguments:
- Parameters:
key - The header key
value - The header value. to_s will be called on the value to determine
the actual String value to insert.
- Returns:
- self so multiple operations can be chained.
|
Write a to the request body.
Keyword arguments:
- Parameters:
chunk - The buffer to write.
handler - The handler will be called when the buffer has actually been
written to the wire.
- Returns:
- self So multiple operations can be chained.
- Overrides:
streams.WriteStream.write_buffer
|
write_str(self,
str,
enc="UTF-8",
handler=None)
| source code
|
Write a to the request body.
Keyword arguments:
- Parameters:
str - The string to write.
enc - The encoding to use.
handler - The handler will be called when the buffer has actually been
written to the wire.
- Returns:
- self So multiple operations can be chained.
|
Forces the head of the request to be written before end is called on
the request. This is normally used to implement HTTP 100-continue
handling, see continue_handler for more information.
- Returns:
- self So multiple operations can be chained.
|
Ends the request. If no data has been written to the request body, and
send_head has not been called then the actual request won't get written
until this method gets called. Once the request has ended, it cannot be
used any more, and if keep alive is true the underlying connection will
be returned to the HttpClient pool so it can be assigned to another
request.
|
Same as write_buffer_and_end but writes a String
Keyword arguments:
- Parameters:
str - The String to write
enc - The encoding
|
Same as end but writes some data to the response body before ending.
If the response is not chunked and no other data has been written then
the Content-Length header will be automatically set
Keyword arguments:
- Parameters:
chunk - The Buffer to write
|
Sets whether the request should used HTTP chunked encoding or not.
Keyword arguments:
- Parameters:
val - If val is true, this request will use HTTP chunked encoding, and
each call to write to the body will correspond to a new HTTP
chunk sent on the wire. If chunked encoding is used the HTTP
header 'Transfer-Encoding' with a value of 'Chunked' will be
automatically inserted in the request.
If chunked is false, this request will not use HTTP chunked
encoding, and therefore if any data is written the body of the
request, the total size of that data must be set in the
'Content-Length' header before any data is written to the request
body.
- Returns:
- self So multiple operations can be chained.
|
If you send an HTTP request with the header 'Expect' set to the value
'100-continue' and the server responds with an interim HTTP response with
a status code of '100' and a continue handler has been set using this
method, then the handler will be called. You can then continue to write
data to the request body and later end it. This is normally used in
conjunction with the send_head method to force the request header to be
written before the request has ended.
Keyword arguments:
- Parameters:
|