class Crest::Request
 
  - Crest::Request
- Reference
- Object
Overview
A class that used to make the requests
The result of a Crest::Request is a Crest::Response object.
Simple example:
request = Crest::Request.new(:post, "http://httpbin.org/post", {"age" => 27}, params: {:name => "Kurt"})
request.execute
Crest::Request.execute(:post, "http://httpbin.org/post", {"age" => 27}, json: true)
Crest::Request.post("http://httpbin.org/post", {"age" => 27}, json: true)Block style:
request = Crest::Request.new(:get, "http://httpbin.org/get") do |request|
  request.headers.add("foo", "bar")
  request.user = "username"
  request.password = "password"
end
response = request.executeMandatory parameters:
- method
- url
Optional parameters:
- headersa hash containing the request headers
- cookiesa hash containing the request cookies
- forma hash containing form data (or a raw string)
- paramsa hash that represent query params (or a raw string) - a string separated from the preceding part by a question mark (?) and a sequence of attribute–value pairs separated by a delimiter (&).
- params_encoderparams encoder (default to- Crest::FlatParamsEncoder)
- authaccess authentication method- basicor- digest(default to- basic)
- userand- passwordfor authentication
- tlsconfiguring TLS settings
- p_addr,- p_port,- p_user,- p_passfor proxy
- jsonmake a JSON request with the appropriate HTTP headers (default to- false)
- multipartmake a multipart request with the appropriate HTTP headers even if not sending a file (default to- false)
- user_agentset "User-Agent" HTTP header (default to- Crest::USER_AGENT)
- max_redirectsmaximum number of redirects (default to- 10)
- loggingenable logging (default to- false)
- loggerset logger (default to- Crest::CommonLogger)
- handle_errorserror handling (default to- true)
- close_connectionclose the connection after request is completed (default to- true)
- http_clientinstance of- HTTP::Client
- read_timeoutread timeout (default to- nil)
- write_timeoutwrite timeout (default to- nil)
- connect_timeoutconnect timeout (default to- nil)
Defined in:
lib/crest/src/crest/request.crext/crest.cr
Constructors
- 
        .new(method : Symbol, url : String, form = {} of String => String, **args)
        
          When block is not given. 
Constructor Detail
When block is not given.