Module: Pincers::Http::Utils
Constant Summary collapse
- FORM_URLENCODED =
'application/x-www-form-urlencoded'
- FORM_MULTIPART =
'multipart/form-data'
- URI_PARSER =
URI::Parser.new(:UNRESERVED => URI::REGEXP::PATTERN::UNRESERVED + '|')
Instance Method Summary collapse
- #encode_multipart(_pairs) ⇒ Object
- #encode_urlencoded(_pairs) ⇒ Object
- #hash_to_pairs(_hash) ⇒ Object
- #parse_uri(_url) ⇒ Object
Instance Method Details
#encode_multipart(_pairs) ⇒ Object
16 17 18 |
# File 'lib/pincers/http/utils.rb', line 16 def encode_multipart(_pairs) raise Pincers::MissingFeatureError.new :encode_multipart end |
#encode_urlencoded(_pairs) ⇒ Object
11 12 13 14 |
# File 'lib/pincers/http/utils.rb', line 11 def encode_urlencoded(_pairs) _pairs = hash_to_pairs _pairs if _pairs.is_a? Hash _pairs.map { |p| "#{p[0]}=#{CGI.escape(p[1])}" }.join '&' end |
#hash_to_pairs(_hash) ⇒ Object
20 21 22 |
# File 'lib/pincers/http/utils.rb', line 20 def hash_to_pairs(_hash) pair_recursive [], _hash end |
#parse_uri(_url) ⇒ Object
24 25 26 |
# File 'lib/pincers/http/utils.rb', line 24 def parse_uri(_url) URI_PARSER.parse _url end |