Class: HTTP::FormData::Urlencoded
- Inherits:
-
Object
- Object
- HTTP::FormData::Urlencoded
- Defined in:
- lib/http/form_data/urlencoded.rb
Overview
application/x-www-form-urlencoded form data.
Instance Method Summary collapse
-
#content_length ⇒ Fixnum
Returns form data content size to be used for HTTP request
Content-Lengthheader. -
#content_type ⇒ String
Returns MIME type to be used for HTTP request
Content-Typeheader. -
#initialize(data) ⇒ Urlencoded
constructor
A new instance of Urlencoded.
-
#to_s ⇒ String
Returns content to be used for HTTP request body.
Constructor Details
#initialize(data) ⇒ Urlencoded
Returns a new instance of Urlencoded.
8 9 10 |
# File 'lib/http/form_data/urlencoded.rb', line 8 def initialize(data) @data = FormData.ensure_hash data end |
Instance Method Details
#content_length ⇒ Fixnum
Returns form data content size to be used for HTTP request
Content-Length header.
30 31 32 |
# File 'lib/http/form_data/urlencoded.rb', line 30 def content_length to_s.bytesize end |
#content_type ⇒ String
Returns MIME type to be used for HTTP request Content-Type header.
22 23 24 |
# File 'lib/http/form_data/urlencoded.rb', line 22 def content_type "application/x-www-form-urlencoded" end |
#to_s ⇒ String
Returns content to be used for HTTP request body.
15 16 17 |
# File 'lib/http/form_data/urlencoded.rb', line 15 def to_s ::URI.encode_www_form @data end |