An HTTP client API for Ruby. Net::HTTP provides a rich library which can be used to build HTTP user-agents.
Questions tagged [net-http]
450 questions
7
votes
1 answer
Ruby Open-URI library aborted in 404 HTTP error code
I use OpenURI library.
object = open("http://example.com")
If http://example.com server code response is equals to 200 my program acts as I expected.
But if http://example.com server response code is equals to 400 (or other) then script aborts…

Sergey Blohin
- 600
- 1
- 4
- 31
7
votes
1 answer
Ruby Proxy Authentication GET/POST with OpenURI or net/http
I'm using ruby 1.9.3 and trying to use open-uri to get a url and try posting using Net:HTTP
Im trying to use proxy authentication for both:
Trying to do a POST request with net/http:
require 'net/http'
require 'open-uri'
http =…

Tarang
- 75,157
- 39
- 215
- 276
6
votes
3 answers
ruby net/http opening connection very slow
When I'm working with net/http in development it is extremely slow. I've installed net-http-spy gem to get some info about each request and I've found out that "opening connection" part takes the most time (more than 10 seconds). Further more, it…

Milovan Zogovic
- 1,541
- 2
- 16
- 24
6
votes
2 answers
Why do I get "Errno::ECONNREFUSED" with 'net/http' in Rails?
I am trying to parse an XML file from a URL. When I try something like this:
require 'net/http'
require 'rubygems'
require 'xmlsimple'
url = 'http://my-address.com/xmltest/note.xml'
xml_data = Net::HTTP.get_response(URI.parse(url)).body
Everything…

user1946705
- 2,858
- 14
- 41
- 58
6
votes
2 answers
ruby (rails) Net::HTTPResponse undefined method closed?
Ruby-on-Rails, Net::HTTPResponse
NoMethodError:undefined method `closed?' for nil:NilClass
Hello, I have faced an issue:
I use the RSpec framework and I need to mock a response within a method which I test.
here is a sample of the method:
def…

Timo Moss
- 83
- 1
- 8
6
votes
0 answers
Errno::EBADF: Bad file descriptor with ruby net/http
What can cause while making an HTTP connection to return EBADF (Bad file descriptor).
Here is my following code wherein the HTTP connection is made. Although the error is very less now(happening very less) but before I put those error on rescue I…

Ratatouille
- 1,372
- 5
- 23
- 50
6
votes
3 answers
How to add headers info using Transport in golang net/http
I am trying to control keep-alives session to reuse the tcp connection by creating a Trasport.
Here is my snippet and I am not sure how to add headers info for authentication.
url := "http://localhost:8181/api/v1/resource"
tr := &http.Transport{
…

James Sapam
- 16,036
- 12
- 50
- 73
6
votes
1 answer
Capybara increase max allowed page load time
I have a page that sometimes loads in over a minute. Assume this is the expected behavior and wont change. In these cases, I get Net::ReadTimeout.
Note that this is after navigating to a page by clicking a button on the previous page, not an ajax…

ndnenkov
- 35,425
- 9
- 72
- 104
6
votes
2 answers
Net::HTTP extremely slow responses for HTTPS requests
For some reason, on my development machine I'm getting very, very slow responses for HTTPS requests performed via Net::HTTP. I've tried RestClient and HTTParty and they both have the same issue. It seems to have sprung from nowhere. I've made these…

lookitsatravis
- 712
- 5
- 15
6
votes
2 answers
Posting Ruby data in JSON format with Net/http
I have this ruby file:
require 'net/http'
require 'json'
require 'uri'
#test data
newAcctJson ='{
"type": "Credit Card",
"nickname": "MoreTesting",
"rewards": 2,
"balance": 50
}'
#creates a new account
def createAcct(custID, json)
…

TomP
- 133
- 1
- 2
- 12
6
votes
3 answers
Getting Headers from a Ruby Net::HTTP Request before making the request
In Ruby, how can I get hold of the HTTP Request Headers that will be sent by a net/http(s) or open-uri request BEFORE it actually makes the request.
In some cases, headers are used when creating a signed string in a URI. Surely there is some way…

rewolf
- 5,561
- 4
- 40
- 51
5
votes
0 answers
ruby net/http openssl security level
Is it possible to set security level in ruby when calling net::http instead of modifying openssl config?
I found out that OpenSSL has a way how to set security level through
OpenSSL::SSL::SSLContext#security_level
but how can I use it in new…

Mi Ro
- 740
- 1
- 6
- 31
5
votes
1 answer
Timeout error when making get request on specific site using ruby 2.5.3
Can anyone get a proper response from the site www.coupang.com?
I keep making requests to "https://www.coupang.com/" and I get an error 9 out of 10 times.(Sometimes it works! Surprisingly.)
Traceback (most recent call last):
14: from…

Jamie
- 61
- 4
5
votes
1 answer
Ruby Net::HTTP second request when timeout
I noticed that when a http request times out, Ruby (2.6.1) makes a second request. This causes problems with one of our endpoints, because a second worker is triggered which takes up resources.
You can see an example here: Go to…

23tux
- 14,104
- 15
- 88
- 187
5
votes
2 answers
ruby-openid: @socket not set while performing discovery
I'm having a bit of truble with omniauth/openid.
When trying to authenticate, I found this in my logs:
OpenID::FetchingError: Error fetching https://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username: undefined…

Andrei Serdeliuc ॐ
- 5,828
- 5
- 39
- 66