Class: Net::HTTPGenericRequest

Inherits:
Object
  • Object
show all
Includes:
HTTPHeader
Defined in:
lib/net/http.rb

Overview

Parent of HTTPRequest class. Do not use this directly; use a subclass of HTTPRequest.

Mixes in the HTTPHeader module.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from HTTPHeader

#[], #[]=, #add_field, #basic_auth, #chunked?, #connection_close?, #connection_keep_alive?, #content_length, #content_length=, #content_range, #content_type, #delete, #each_capitalized, #each_capitalized_name, #each_header, #each_name, #each_value, #fetch, #get_fields, #initialize_http_header, #key?, #main_type, #proxy_basic_auth, #range, #range_length, #set_content_type, #set_form_data, #set_range, #size, #sub_type, #to_hash, #type_params

Constructor Details

- (HTTPGenericRequest) initialize(m, reqbody, resbody, path, initheader = nil)

A new instance of HTTPGenericRequest

Raises:

  • (ArgumentError)


1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
# File 'lib/net/http.rb', line 1657

def initialize(m, reqbody, resbody, path, initheader = nil)
  @method = m
  @request_has_body = reqbody
  @response_has_body = resbody
  raise ArgumentError, "no HTTP request path given" unless path
  raise ArgumentError, "HTTP request path is empty" if path.empty?
  @path = path
  initialize_http_header initheader
  self['Accept'] ||= '*/*'
  self['User-Agent'] ||= 'Ruby'
  @body = nil
  @body_stream = nil
end

Instance Attribute Details

- (Object) body

Returns the value of attribute body



1691
1692
1693
# File 'lib/net/http.rb', line 1691

def body
  @body
end

- (Object) body_stream

Returns the value of attribute body_stream



1699
1700
1701
# File 'lib/net/http.rb', line 1699

def body_stream
  @body_stream
end

- (Object) method (readonly)

Returns the value of attribute method



1671
1672
1673
# File 'lib/net/http.rb', line 1671

def method
  @method
end

- (Object) path (readonly)

Returns the value of attribute path



1672
1673
1674
# File 'lib/net/http.rb', line 1672

def path
  @path
end

Instance Method Details

- (Boolean) body_exist?

Returns:

  • (Boolean)


1686
1687
1688
1689
# File 'lib/net/http.rb', line 1686

def body_exist?
  warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
  response_body_permitted?
end

- (Object) exec(sock, ver, path)

write



1716
1717
1718
1719
1720
1721
1722
1723
1724
# File 'lib/net/http.rb', line 1716

def exec(sock, ver, path)   #:nodoc: internal use only
  if @body
    send_request_with_body sock, ver, path, @body
  elsif @body_stream
    send_request_with_body_stream sock, ver, path, @body_stream
  else
    write_header sock, ver, path
  end
end

- (Object) inspect



1674
1675
1676
# File 'lib/net/http.rb', line 1674

def inspect
  "\#<#{self.class} #{@method}>"
end

- (Boolean) request_body_permitted?

Returns:

  • (Boolean)


1678
1679
1680
# File 'lib/net/http.rb', line 1678

def request_body_permitted?
  @request_has_body
end

- (Boolean) response_body_permitted?

Returns:

  • (Boolean)


1682
1683
1684
# File 'lib/net/http.rb', line 1682

def response_body_permitted?
  @response_has_body
end

- (Object) set_body_internal(str)

:nodoc: internal use only

Raises:

  • (ArgumentError)


1707
1708
1709
1710
# File 'lib/net/http.rb', line 1707

def set_body_internal(str)   #:nodoc: internal use only
  raise ArgumentError, "both of body argument and HTTPRequest#body set" if str and (@body or @body_stream)
  self.body = str if str
end