Class: Net::HTTPGenericRequest
- Inherits:
-
Object
- Object
- Net::HTTPGenericRequest
- Includes:
- HTTPHeader
- Defined in:
- lib/net/http.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#body_stream ⇒ Object
Returns the value of attribute body_stream.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #body_exist? ⇒ Boolean
-
#exec(sock, ver, path) ⇒ Object
write.
-
#initialize(m, reqbody, resbody, path, initheader = nil) ⇒ HTTPGenericRequest
constructor
A new instance of HTTPGenericRequest.
- #inspect ⇒ Object
- #request_body_permitted? ⇒ Boolean
- #response_body_permitted? ⇒ Boolean
-
#set_body_internal(str) ⇒ Object
:nodoc: internal use only.
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, #set_form_data, #set_range, #size, #sub_type, #to_hash, #type_params
Constructor Details
#initialize(m, reqbody, resbody, path, initheader = nil) ⇒ HTTPGenericRequest
Returns a new instance of HTTPGenericRequest.
1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 |
# File 'lib/net/http.rb', line 1855 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 @body_data = nil end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
1890 1891 1892 |
# File 'lib/net/http.rb', line 1890 def body @body end |
#body_stream ⇒ Object
Returns the value of attribute body_stream
1899 1900 1901 |
# File 'lib/net/http.rb', line 1899 def body_stream @body_stream end |
#method ⇒ Object (readonly)
Returns the value of attribute method
1870 1871 1872 |
# File 'lib/net/http.rb', line 1870 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path
1871 1872 1873 |
# File 'lib/net/http.rb', line 1871 def path @path end |
Instance Method Details
#body_exist? ⇒ Boolean
1885 1886 1887 1888 |
# File 'lib/net/http.rb', line 1885 def body_exist? warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE response_body_permitted? end |
#exec(sock, ver, path) ⇒ Object
write
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 |
# File 'lib/net/http.rb', line 1917 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 elsif @body_data send_request_with_body_data sock, ver, path, @body_data else write_header sock, ver, path end end |
#inspect ⇒ Object
1873 1874 1875 |
# File 'lib/net/http.rb', line 1873 def inspect "\#<#{self.class} #{@method}>" end |
#request_body_permitted? ⇒ Boolean
1877 1878 1879 |
# File 'lib/net/http.rb', line 1877 def request_body_permitted? @request_has_body end |
#response_body_permitted? ⇒ Boolean
1881 1882 1883 |
# File 'lib/net/http.rb', line 1881 def response_body_permitted? @response_has_body end |
#set_body_internal(str) ⇒ Object
:nodoc: internal use only
1908 1909 1910 1911 |
# File 'lib/net/http.rb', line 1908 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 |