| Class | Rev::HttpClient |
| In: |
lib/rev/http_client.rb
|
| Parent: | TCPSocket |
HTTP client class implemented as a subclass of Rev::TCPSocket. Encodes requests and allows streaming consumption of the response. Response is parsed with a Ragel-generated whitelist parser which supports chunked HTTP encoding.
loop = Rev::Loop.default
client = Rev::HttpClient.connect("www.google.com").attach
client.get('/search', query: {q: 'foobar'})
loop.run
| ALLOWED_METHODS | = | [:put, :get, :post, :delete, :head] |
| TRANSFER_ENCODING | = | "TRANSFER_ENCODING" |
| CONTENT_LENGTH | = | "CONTENT_LENGTH" |
| SET_COOKIE | = | "SET_COOKIE" |
| LOCATION | = | "LOCATION" |
| HOST | = | "HOST" |
| CRLF | = | "\r\n" |
Send an HTTP request and consume the response. Supports the following options:
head: {Key: Value}
Specify an HTTP header, e.g. {'Connection': 'close'}
query: {Key: Value}
Specify query string parameters (auto-escaped)
cookies: {Key: Value}
Specify hash of cookies (auto-escaped)
body: String
Specify the request body (you must encode it for now)