Ruby Net::HTTPHeader Functions

EditRocket provides the following information on Net::HTTPHeader functions in the Ruby source code builder.

add_field(key, val) - "[Ruby 1.8.3] Adds header field instead of replace. Second argument val must be a String. See also #[]=, #[] and #get_fields."

basic_auth(account, password) - "Set the Authorization: header for "Basic" authorization."

canonical_each() - "Alias for #each_capitalized"

chunked?() - Returns "true" if the "transfer-encoding" header is present and set to "chunked". This is an HTTP/1.1 feature, allowing the the content to be sent in "chunks" without at the outset stating the entire content length.

content_length=(len) -

content_length() - "Returns an Integer object which represents the Content-Length: header field or nil if that field is not provided."

content_range() - "Returns a Range object which represents Content-Range: header field. This indicates, for a partial entity body, where this fragment fits inside the full entity body, as range of byte offsets."

content_type=(type, params = {}) - "Alias for #set_content_type"

content_type() - "Returns a content type string such as "text/html". This method returns nil if Content-Type: header field does not exist."

delete(key) - Removes a header field.

each( - "Alias for #each_header"

each_capitalized() - "As for #each_header, except the keys are provided in capitalized form."

each_capitalized_name() - Iterates for each capitalized header names.

each_header( {|+key+, +value+| ...} - Iterates for each header names and values.

each_key() - "Alias for #each_name"

each_name() - Iterates for each header names.

each_value( {|+value+| ...} - Iterates for each header values.

fetch(key, *args) - Returns the header field corresponding to the case-insensitive key. Returns the default value args, or the result of the block, or nil, if there's no header field named key. See Hash#fetch

form_data=(params, sep = '&') - "Alias for #set_form_data"

get_fields(key) - "[Ruby 1.8.3] Returns an array of header field strings corresponding to the case-insensitive key. This method allows you to get duplicated header fields without any processing. See also #[]."

initialize_http_header(initheader) -

key?(key) - true if key header exists.

main_type() - "Returns a content type string such as "text". This method returns nil if Content-Type: header field does not exist."

proxy_basic_auth(account, password) - "Set Proxy-Authorization: header for "Basic" authorization."

range=(r, e = nil) - "Alias for #set_range"

range() - "Returns an Array of Range objects which represents Range: header field, or nil if there is no such header."

range_length() - "The length of the range represented in Content-Range: header."

set_content_type(type, params = {}) - "Set Content-Type: header field by type and params. type must be a String, params must be a Hash."

set_form_data(params, sep = '&') - Set header fields and a body from HTML form data. params should be a Hash containing HTML form data. Optional argument sep means data record separator.

set_range(r, e = nil) - "Set Range: header from Range (arg r) or beginning index and length from it (arg idx&len)."

sub_type() - "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() - Returns a Hash consist of header names and values.

type_params() - Returns content type parameters as a Hash as like {"charset" => "iso-2022-jp"}.