Sha256: e847d64b15471e760c6cd4b4a5daa409cff574b38e6969c13b1b04fc952031e3

Contents?: true

Size: 985 Bytes

Versions: 54

Compression:

Stored size: 985 Bytes

Contents

module RestClient
  # The response from RestClient on a raw request looks like a string, but is
  # actually one of these.  99% of the time you're making a rest call all you
  # care about is the body, but on the occassion you want to fetch the
  # headers you can:
  #
  #   RestClient.get('http://example.com').headers[:content_type]
  #
  # In addition, if you do not use the response as a string, you can access
  # a Tempfile object at res.file, which contains the path to the raw
  # downloaded request body.
  class RawResponse

    include AbstractResponse

    attr_reader :file, :request

    def inspect
      "<RestClient::RawResponse @code=#{code.inspect}, @file=#{file.inspect}, @request=#{request.inspect}>"
    end

    def initialize(tempfile, net_http_res, request)
      @net_http_res = net_http_res
      @file = tempfile
      @request = request
    end

    def to_s
      @file.open
      @file.read
    end

    def size
      File.size file
    end

  end
end

Version data entries

54 entries across 47 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rest-client-2.0.2/lib/restclient/raw_response.rb