Class Typhoeus::Request
In: lib/typhoeus/request.rb
lib/typhoeus/request/actions.rb
lib/typhoeus/request/memoizable.rb
lib/typhoeus/request/callbacks.rb
lib/typhoeus/request/streamable.rb
lib/typhoeus/request/marshal.rb
lib/typhoeus/request/operations.rb
lib/typhoeus/request/stubbable.rb
lib/typhoeus/request/block_connection.rb
lib/typhoeus/request/responseable.rb
lib/typhoeus/request/before.rb
lib/typhoeus/request/cacheable.rb
Parent: Object

This class represents a request.

@example (see initialize)

@example Make a request with the shortcut.

  response = Typhoeus.get("www.example.com")

@see (see initialize)

Methods

cache_key   encoded_body   eql?   hash   new   url  

Included Modules

Request::Callbacks::Types Request::Callbacks Request::Streamable Request::Marshal Request::Operations Request::Responseable Request::Memoizable Request::Cacheable Request::BlockConnection Request::Stubbable Request::Before

Classes and Modules

Module Typhoeus::Request::Actions
Module Typhoeus::Request::Before
Module Typhoeus::Request::BlockConnection
Module Typhoeus::Request::Cacheable
Module Typhoeus::Request::Callbacks
Module Typhoeus::Request::Marshal
Module Typhoeus::Request::Memoizable
Module Typhoeus::Request::Operations
Module Typhoeus::Request::Responseable
Module Typhoeus::Request::Streamable
Module Typhoeus::Request::Stubbable

Attributes

base_url  [RW]  Returns the provided base url.

@return [ String ]

block_connection  [RW]  @return [ Boolean ]

@api private

hydra  [RW]  Returns the hydra in which the request ran, if any.

@return [ Typhoeus::Hydra ]

@api private

options  [RW]  Returns options, which includes default parameters.

@return [ Hash ]

original_options  [RW]  Returns the original options provided.

@return [ Hash ]

@api private

Public Class methods

Creates a new request.

@example Simplest request.

  response = Typhoeus::Request.new("www.example.com").run

@example Request with url parameters.

  response = Typhoeus::Request.new(
    "www.example.com",
    params: {a: 1}
  ).run

@example Request with a body.

  response = Typhoeus::Request.new(
    "www.example.com",
    body: {b: 2}
  ).run

@example Request with parameters and body.

  response = Typhoeus::Request.new(
    "www.example.com",
    params: {a: 1},
    body: {b: 2}
  ).run

@example Create a request and allow follow redirections.

  response = Typhoeus::Request.new(
    "www.example.com",
    followlocation: true
  ).run

@param [ String ] base_url The url to request. @param [ options ] options The options.

@option options [ Hash ] :params Translated

  into url parameters.

@option options [ Hash ] :body Translated

  into HTTP POST request body.

@return [ Typhoeus::Request ] The request.

@note See {rubydoc.info/github/typhoeus/ethon/Ethon/Easy/Options Ethon::Easy::Options} for more options.

@see Typhoeus::Hydra @see Typhoeus::Response @see Typhoeus::Request::Actions

Public Instance methods

Returns a cache key for use with caching methods that required a string for a key. Will get used by ActiveSupport::Cache stores automatically.

@return [ String ] The cache key.

Mimics libcurls POST body generation. This is not accurate, but good enough for VCR.

@return [ String ] The encoded body.

  otherwise.

@api private

Returns whether other is equal to self.

@example Are request equal?

  request.eql?(other_request)

@param [ Object ] other The object to check.

@return [ Boolean ] Returns true if equal, else false.

@api private

Overrides Object#hash.

@return [ Integer ] The integer representing the request.

@api private

Return the url. In contrast to base_url which returns the value you specified, url returns the full url including the parameters.

@example Get the url.

  request.url

@since 0.5.5

[Validate]