Actions
Bug #20077
closedmodern http client
Description
net/http is very very old and hard to use.
we need a well designed http client in stdlib.
Actions
Like0
Like0Like0Like0Like0Like0
Added by pynix (Pynix wang) over 1 year ago. Updated over 1 year ago.
Description
net/http is very very old and hard to use.
we need a well designed http client in stdlib.
It would be good if you could outline in more detail:
Without a more specific use-case beyond "net/http is hard to use" it's hard to have a meaningful discussion.
For GET and POST, modern Ruby does have APIs that aren't hard to use. I wonder if you have used them.
Net::HTTP.get(uri, headers = {})
: Ruby 3.0+ https://bugs.ruby-lang.org/issues/16686
Net::HTTP.post(uri, body, headers = {})
: Ruby 2.4+ https://bugs.ruby-lang.org/issues/12375
HTTP.get return body as string,
other http method return response
there is get_print, maybe for scripting.
HTTP:Client api is also hard to use.
can we deprecate net/*
and get an modern http client (or server) in std.
http.rb is great.
HTTP.get return body as string,
other http method return response
there is get_print, maybe for scripting.
If you look at what HTTP.get
does, it's just HTTP.get_response(...).body
. You may use HTTP.get_response
for that purpose.
I know,but this is the bad part,they are http verb,but some return response,some return body string.
all verb method should return response object, modify net/http will break compatibility.
so I suggest opt out net/http and webrick, introduce new http/client and http/server based on llhttp that nodejs used.