module Puppy

Defined in:

puppy.cr
puppy/fetch.cr
puppy/version.cr

Constant Summary

UA = "Puppy #{VERSION}"

Class Method Summary

Class Method Detail

def self.delete(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a DELETE request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.delete("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.delete(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a DELETE request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.delete "https://www.example.com", form: "foo=bar"

[View source]
def self.delete(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a DELETE request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.delete "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.exec(request : HTTP::Request, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"
request = HTTP::Request.new "GET", "https://www.example.com"
response = Puppy.exec(request, decompress: true, timeout: 10.seconds, trust_all_certs: false, proxy_addr: "http://proxy_host:proxy_prort")
response.body_io.gets_to_end # => "..."

[View source]
def self.get(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a GET request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.get("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.get(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a GET request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.get "https://www.example.com", form: "foo=bar"

[View source]
def self.get(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a GET request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.get "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.head(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a HEAD request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.head("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.head(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a HEAD request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.head "https://www.example.com", form: "foo=bar"

[View source]
def self.head(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a HEAD request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.head "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.options(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a OPTIONS request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.options("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.options(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a OPTIONS request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.options "https://www.example.com", form: "foo=bar"

[View source]
def self.options(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a OPTIONS request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.options "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.patch(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PATCH request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.patch("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.patch(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PATCH request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.patch "https://www.example.com", form: "foo=bar"

[View source]
def self.patch(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PATCH request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.patch "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.post(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a POST request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.post("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.post(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a POST request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.post "https://www.example.com", form: "foo=bar"

[View source]
def self.post(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a POST request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.post "https://www.example.com", form: {"foo" => "bar"}

[View source]
def self.put(path : String, headers : HTTP::Headers | Nil = nil, body : IO | Bytes | String | Nil = nil, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PUT request. The response will have its body_io as a IO, accessed via HTTP::Client::Response#body_io.

require "puppy"

response = Puppy.put("https://www.example.com", headers: HTTP::Headers{"User-Agent" => "AwesomeApp"}, body: "Hello!")
response.body_io.gets_to_end #=> "..."

[View source]
def self.put(path, headers : HTTP::Headers | Nil = nil, *, form : String | IO, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PUT request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.put "https://www.example.com", form: "foo=bar"

[View source]
def self.put(path, headers : HTTP::Headers | Nil = nil, *, form : Hash(String, String) | NamedTuple, decompress : Bool = true, timeout : Time::Span = 10.seconds, trust_all_certs : Bool = false, proxy_addr : String | Nil = nil) : HTTP::Client::Response #

Executes a PUT request with form data and returns a Response. The "Content-Type" header is set to "application/x-www-form-urlencoded".

require "puppy"

response = Puppy.put "https://www.example.com", form: {"foo" => "bar"}

[View source]