In Files

  • net/http/generic_request.rb

Class/Module Index [+]

Quicksearch

Net::HTTPGenericRequest

HTTPGenericRequest is the parent of the HTTPRequest class. Do not use this directly; use a subclass of HTTPRequest.

Mixes in the HTTPHeader module to provide easier access to HTTP headers.

Attributes

body[R]
body_stream[R]
decode_content[R]

Automatically set to false if the user sets the Accept-Encoding header. This indicates they wish to handle Content-encoding in responses themselves.

method[R]
path[R]
uri[R]

Public Class Methods

new(m, reqbody, resbody, uri_or_path, initheader = nil) click to toggle source
 
               # File net/http/generic_request.rb, line 10
def initialize(m, reqbody, resbody, uri_or_path, initheader = nil)
  @method = m
  @request_has_body = reqbody
  @response_has_body = resbody

  if URI === uri_or_path then
    @uri = uri_or_path.dup
    host = @uri.hostname
    host += ":#{@uri.port}" if @uri.port != @uri.class::DEFAULT_PORT
    path = uri_or_path.request_uri
  else
    @uri = nil
    host = nil
    path = uri_or_path
  end

  raise ArgumentError, "no HTTP request path given" unless path
  raise ArgumentError, "HTTP request path is empty" if path.empty?
  @path = path

  @decode_content = false

  if @response_has_body and Net::HTTP::HAVE_ZLIB then
    if !initheader ||
       !initheader.keys.any? { |k|
         %w[accept-encoding range].include? k.downcase
       } then
      @decode_content = true
      initheader = initheader ? initheader.dup : {}
      initheader["accept-encoding"] =
        "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
    end
  end

  initialize_http_header initheader
  self['Accept'] ||= '*/*'
  self['User-Agent'] ||= 'Ruby'
  self['Host'] ||= host
  @body = nil
  @body_stream = nil
  @body_data = nil
end
            

Public Instance Methods

body=(str) click to toggle source
 
               # File net/http/generic_request.rb, line 91
def body=(str)
  @body = str
  @body_stream = nil
  @body_data = nil
  str
end
            
body_exist?() click to toggle source
 
               # File net/http/generic_request.rb, line 84
def body_exist?
  warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
  response_body_permitted?
end
            
body_stream=(input) click to toggle source
 
               # File net/http/generic_request.rb, line 100
def body_stream=(input)
  @body = nil
  @body_stream = input
  @body_data = nil
  input
end
            
inspect() click to toggle source
 
               # File net/http/generic_request.rb, line 62
def inspect
  "\#<#{self.class} #{@method}>"
end
            
request_body_permitted?() click to toggle source
 
               # File net/http/generic_request.rb, line 76
def request_body_permitted?
  @request_has_body
end
            
response_body_permitted?() click to toggle source
 
               # File net/http/generic_request.rb, line 80
def response_body_permitted?
  @response_has_body
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus