sub_type

sub_type() Instance Public methods Returns a content type string such as âhtmlâ. This method returns nil if Content-Type: header field does not exist or sub-type is not given (e.g. âContent-Type: textâ).

to_hash

to_hash() Instance Public methods Returns a Hash consisting of header names and values. e.g. {âcache-controlâ => âprivateâ, "content-type" => "text/html", "date" => "Wed, 22 Jun 2005 22:11:50 GMT"}

type_params

type_params() Instance Public methods Any parameters specified for the content type, returned as a Hash. For example, a header of Content-Type: text/html; charset=EUC-JP would result in #type_params returning {'charset' => 'EUC-JP'}

new

new(path, initheader = nil) Class Public methods Creates an HTTP request object for path. initheader are the default headers to use. Net::HTTP adds Accept-Encoding to enable compression of the response body unless Accept-Encoding or Range are supplied in initheader.

body_permitted?

body_permitted?() Class Public methods true if the response has a body.

body

body() Instance Public methods Returns the full entity body. Calling this method a second or subsequent time will return the string already read. http.request_get('/index.html') {|res| puts res.body } http.request_get('/index.html') {|res| p res.body.object_id # 538149362 p res.body.object_id # 538149362 } entity

body=

body=(value) Instance Public methods Because it may be necessary to modify the body, Eg, decompression this method facilitates that.

entity

entity() Instance Public methods Alias for: body

inspect

inspect() Instance Public methods

read_body

read_body(dest = nil, &block) Instance Public methods Gets the entity body returned by the remote HTTP server. If a block is given, the body is passed to the block, and the body is provided in fragments, as it is read in from the socket. Calling this method a second or subsequent time for the same HTTPResponse object will return the value already read. http.request_get('/index.html') {|res| puts res.read_body } http.request_get('/index.html') {|res| p res.read_body.object_