Project

General

Profile

Actions

Feature #12375

closed

Net::HTTP.post

Added by shugo (Shugo Maeda) over 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:75484]

Description

Net::HTTP.post_form is convenient, but it's dedicated to application/x-www-form-urlencoded.
Why not provide Net::HTTP.post for other media types?

res = Net::HTTP.post(URI('http://www.example.com/api/search'),
                     { "q" => "ruby", "max" => "50" }.to_json,
                     "Content-Type" => "application/json")

I've attached a patch, but there are some considerations:

  • Net::HTTP.post_form supports basic authentication by userinfo in URLs,
    but Net::HTTP.post doesn't, because it's deprecated by RFC3986.
    Is it OK?
  • The first argument must be a URI object, but it might be better to accept a String.
  • Should methods for other HTTP methods such as Net::HTTP.patch be added?

Files

net_http_s_post.diff (1.76 KB) net_http_s_post.diff shugo (Shugo Maeda), 05/13/2016 07:55 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0