Project

General

Profile

Feature #16686

Let Net::HTTP.get take request headers

Added by k0kubun (Takashi Kokubun) 11 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:97444]

Description

When we need to write a script requesting an HTTP API with GET method which requires authentication by a request header, it'd be nice if we can simply do:

Net::HTTP.get(URI("https://api.example.com/user"), { "Authorization" => "apikey" })

Currently the arguments of the Net::HTTP.get family are overloaded by (String, String, Integer) and (URI). This ticket aims to extend only the latter one to (URI, Hash).
The new interface will also be consistent with [Feature #12375].

Patch: https://github.com/ruby/ruby/pull/2957

#1

Updated by k0kubun (Takashi Kokubun) 11 months ago

  • Description updated (diff)
#2

Updated by k0kubun (Takashi Kokubun) 11 months ago

  • Description updated (diff)
#3

Updated by k0kubun (Takashi Kokubun) 11 months ago

  • Status changed from Open to Closed

Applied in changeset git|e0512b29aa47d4b79a27b0c0356bf47ec9b4e072.


Let Net::HTTP.get take request headers (#2957)

  • Let Net::HTTP.get take request headers

  • Add more test cases for no header usages

  • Add examples with request headers

  • Add a NEWS entry [ci skip]

[Feature #16686]

Also available in: Atom PDF