class HTTP::FormData::Urlencoded

`application/x-www-form-urlencoded` form data.

Public Class Methods

new(data) click to toggle source

@param [#to_h, Hash] data form data key-value Hash

# File lib/http/form_data/urlencoded.rb, line 10
def initialize(data)
  @data = FormData.ensure_hash data
end

Public Instance Methods

content_length() click to toggle source

Returns form data content size to be used for HTTP request `Content-Length` header.

@return [Integer]

# File lib/http/form_data/urlencoded.rb, line 32
def content_length
  to_s.bytesize
end
content_type() click to toggle source

Returns MIME type to be used for HTTP request `Content-Type` header.

@return [String]

# File lib/http/form_data/urlencoded.rb, line 24
def content_type
  "application/x-www-form-urlencoded"
end
to_s() click to toggle source

Returns content to be used for HTTP request body.

@return [String]

# File lib/http/form_data/urlencoded.rb, line 17
def to_s
  ::URI.encode_www_form @data
end