Class: HTTP::FormData::Urlencoded

Inherits:
Object
  • Object
show all
Includes:
Readable
Defined in:
lib/http/form_data/urlencoded.rb

Overview

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

Instance Method Summary collapse

Methods included from Readable

#read, #rewind, #size, #to_s

Constructor Details

#initialize(data) ⇒ Urlencoded

Returns a new instance of Urlencoded.

Parameters:

  • data (#to_h, Hash)

    form data key-value Hash



15
16
17
18
# File 'lib/http/form_data/urlencoded.rb', line 15

def initialize(data)
  uri_encoded_data = ::URI.encode_www_form FormData.ensure_hash(data)
  @io = StringIO.new(uri_encoded_data)
end

Instance Method Details

#content_typeString

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

Returns:

  • (String)


23
24
25
# File 'lib/http/form_data/urlencoded.rb', line 23

def content_type
  "application/x-www-form-urlencoded"
end