123456789_123456789_123456789_123456789_123456789_

Class: Gem::Net::HTTP::Head

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Gem::Net::HTTPRequest
Defined in: lib/rubygems/vendor/net-http/lib/net/http/requests.rb

Overview

Class for representing {Gem::Net::HTTP method HEAD}:

require 'rubygems/vendor/net-http/lib/net/http'
uri = Gem::URI('http://example.com')
hostname = uri.hostname # => "example.com"
req = Gem::Net::HTTP::Head.new(uri) # => #<Gem::Net::HTTP::Head HEAD>
res = Gem::Net::HTTP.start(hostname) do |http|

http.request(req)

end

See {Gem::Request Headers}.

Properties:

Related:

  • #head: sends HEAD request, returns response object.

Constant Summary

::Gem::Net::HTTPHeader - Included

MAX_FIELD_LENGTH, MAX_KEY_LENGTH

Class Method Summary

::Gem::Net::HTTPRequest - Inherited

.new

Creates an ::Gem::Net::HTTP request object for Gem.path.

::Gem::Net::HTTPGenericRequest - Inherited

Instance Attribute Summary

::Gem::Net::HTTPGenericRequest - Inherited

#body

Returns the string body for the request, or nil if there is none:

#body=

Sets the body for the request:

#body_stream

Returns the body stream object for the request, or nil if there is none:

#body_stream=

Sets the body stream for the request:

#decode_content

Returns false if the request’s header 'Accept-Encoding' has been set manually or deleted (indicating that the user intends to handle encoding in the response), true otherwise:

#method

Returns the string method name for the request:

#path

Returns the string path for the request:

#request_body_permitted?

Returns whether the request may have a body:

#response_body_permitted?

Returns whether the response may have a body:

#uri

Returns the ::Gem::URI object for the request, or nil if none:

#body_exist?

::Gem::Net::HTTPHeader - Included

#chunked?

Returns true if field 'Transfer-Encoding' exists and has value 'chunked', false otherwise; see Transfer-Encoding response header:

#connection_close?

Returns whether the ::Gem::Net::HTTP session is to be closed.

#connection_keep_alive?

Returns whether the ::Gem::Net::HTTP session is to be kept alive.

#content_length

Returns the value of field 'Content-Length' as an integer, or nil if there is no such field; see Content-Length request header:

#content_length=

Sets the value of field 'Content-Length' to the given numeric; see Content-Length response header:

Instance Method Summary

::Gem::Net::HTTPGenericRequest - Inherited

#encode_multipart_form_data, #flush_buffer,
#inspect

Returns a string representation of the request:

#quote_string, #send_request_with_body, #send_request_with_body_data, #send_request_with_body_stream, #supply_default_content_type,
#wait_for_continue

Waits up to the continue timeout for a response from the server provided we’re speaking ::Gem::Net::HTTP 1.1 and are expecting a 100-continue response.

#write_header,
#[]=

Don’t automatically decode response content-encoding if the user indicates they want to handle it.

#exec

write.

#set_body_internal

internal use only.

#update_uri

internal use only.

::Gem::Net::HTTPHeader - Included

#[]

Returns the string field value for the case-insensitive field #key, or nil if there is no such key; see Fields:

#[]=

Sets the value for the case-insensitive #key to val, overwriting the previous value if the field exists; see Fields:

#add_field

Adds value val to the value array for field #key if the field exists; creates the field with the given #key and val if it does not exist.

#basic_auth

Sets header 'Authorization' using the given account and password strings:

#canonical_each
#content_range

Returns a Range object representing the value of field 'Content-Range', or nil if no such field exists; see Content-Range response header:

#content_type

Returns the media type from the value of field 'Content-Type', or nil if no such field exists; see Content-Type response header:

#content_type=
#delete

Removes the header for the given case-insensitive #key (see Fields); returns the deleted value, or nil if no such field exists:

#each
#each_capitalized

Like #each_header, but the keys are returned in capitalized form.

#each_capitalized_name

Calls the block with each capitalized field name:

#each_header

Calls the block with each key/value pair:

#each_key
#each_name

Calls the block with each field key:

#each_value

Calls the block with each string field value:

#fetch

With a block, returns the string value for #key if it exists; otherwise returns the value of the block; ignores the default_val; see Fields:

#form_data=
#get_fields

Returns the array field value for the given #key, or nil if there is no such field; see Fields:

#key?

Returns true if the field for the case-insensitive #key exists, false otherwise:

#main_type

Returns the leading (‘type’) part of the media type from the value of field 'Content-Type', or nil if no such field exists; see Content-Type response header:

#proxy_basic_auth

Sets header 'Proxy-Authorization' using the given account and password strings:

#range

Returns an array of Range objects that represent the value of field 'Range', or nil if there is no such field; see Range request header:

#range=
#range_length

Returns the integer representing length of the value of field 'Content-Range', or nil if no such field exists; see Content-Range response header:

#set_content_type

Sets the value of field 'Content-Type'; returns the new value; see Content-Type request header:

#set_form

Stores form data to be used in a POST or PUT request.

#set_form_data

Sets the request body to a URL-encoded string derived from argument params, and sets request header field 'Content-Type' to 'application/x-www-form-urlencoded'.

#set_range

Sets the value for field 'Range'; see Range request header:

#sub_type

Returns the trailing (‘subtype’) part of the media type from the value of field 'Content-Type', or nil if no such field exists; see Content-Type response header:

#to_hash

Returns a hash of the key/value pairs:

#type_params

Returns the trailing (‘parameters’) part of the value of field 'Content-Type', or nil if no such field exists; see Content-Type response header:

#append_field_value, #basic_encode, #capitalize, #set_field, #initialize_http_header,
#length
#size

obsolete.

Constructor Details

This class inherits a constructor from Gem::Net::HTTPRequest