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
2
votes
1 answer
Ruby 2.3 - Adding Timeout error and notification to net:http request
I have a working system to produce errors and send them to be used by Active Admin.
For example in Active admin, for a specific page of our CMS, the page might execute :
url_must_be_accessible("http://www.exmaple.com", field_url_partner, "URL for…

Mathieu
- 4,587
- 11
- 57
- 112
2
votes
1 answer
Is there opportunity to debug http request in RubyMine?
Appear problem when I try to debug http response with default Ruby lib Net::HTTP
Example. I have such piece of code
url = URI.parse("http://nibbler.silktide.com/") # any http resource
req = Net::HTTP.get_response(url) # the same situation with get…

user2267897
- 23
- 2
2
votes
2 answers
use ruby to get content length of URLs
I am trying to write a ruby script that gets some details about files on a website using net/http. My code looks like this:
require 'open-uri'
require 'net/http'
url = URI.parse asset
res = Net::HTTP.start(url.host, url.port) {|http|
…

Joe Mastey
- 26,809
- 13
- 80
- 104
2
votes
1 answer
How to i get ruby to return json response to be used in rails controller
I'm working with an Api, so far so good i am able to send requests and receive response, but i want the ruby code to send the json response and message that can be accessible from my rails controller so that i can get simple_form to render the error…

codex
- 35
- 1
- 11
2
votes
2 answers
Use Client Cert and TLS_RSA_WITH_AES_256_CBC_SHA and other cipher suites
I am working on an SSL Handshake with a server that requires TLSv1 and above.
They ciphers they support are:
TLS_RSA_WITH_AES_256_CBC_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
TLS_RSA_WITH_AES_128_CBC_SHA
My current connection looks something like…

ruevaughn
- 1,319
- 1
- 17
- 48
2
votes
2 answers
Ruby : Net::HTTP parse adds %0A at end
I'm trying to open a file called test.txt and then import each line in a variable called 'line' and then add it in url file to make request.
require 'net/http'
require 'uri'
puts "Enter URL :-"
gurl = gets.chomp
total =…

Harsh Jaiswal
- 23
- 2
2
votes
2 answers
Stub Net::HTTPCreated response in rspec
I am a uploading image file on another site, and they have provided upload API for the same.
File upload process is divided into 2 parts
Create image Id (POST)
Upload image (PUT)
When I create an image id, it returns id in the response. For this,…

I-am-simple-user
- 409
- 7
- 19
2
votes
0 answers
net/http Net::HTTPMovedPermanently redirection
res['location'] returns the original URL along with this error: #
My code:
uri = URI.parse(url)
res = Net::HTTP.new(uri.host).request(Net::HTTP::Get.new(uri))
puts res['location']
Shouldn't res['location'] return the…

six7zero9
- 313
- 1
- 4
- 15
2
votes
1 answer
In RoR, how do I recover from a "Failed to open TCP connection ... (general SOCKS server failure)" error?
I’m using Rails 4.2.7. Currently Im’ requesting web pages through a SOCKS proxy like so
begin
...
res1 = Net::HTTP.SOCKSProxy('127.0.0.1', 50001).start(uri.host, uri.port) do |http|
puts "launching #{uri}"
resp = http.get(uri)
…
user6447029
2
votes
1 answer
scanning a webpage for urls with ruby and regex
I'm trying to create an array of all links found at the below url. Using page.scan(URI.regexp) or URI.extract(page) returns more than just urls.
How do I get just the urls?
require 'net/http'
require 'uri'
uri =…

Ravenous
- 356
- 1
- 4
- 16
2
votes
1 answer
How do I catch the "Error during processing: buffer error" in Ruby when getting a web page?
I’m using Rails 4.2.7 and this code to get a webpage through a SOCKS proxy …
begin
…
res1 = Net::HTTP.SOCKSProxy('127.0.0.1', 50001).start(uri.host, uri.port) do |http|
puts "launching #{uri}"
resp = http.get(uri)
status…
user6447029
2
votes
1 answer
Download files from URL with Ruby
I have a url that contains many zip files that I need to download local copies of them. I have so far:
require 'open-uri'
require 'pry'
def download_xml(url, dest)
open(url) do |u|
File.open(dest, 'wb') { |f| f.write(u.read) }
end
end
urls…

Daniel Glover
- 21
- 1
- 2
2
votes
1 answer
How to send a request to localhost using 'net/http' fails with end of file reached (EOFError)
I'm using Ruby version 2.3.0.
I want to check when my application is up, and I wrote this method for my "deployer".
At runtime http.request_get(uri) raises
EOFError: end of file reached
when I pass http://localhost as a first argument into the…

arkhwise
- 873
- 9
- 13
2
votes
1 answer
Net:HTTP SSL negotiation timeout on Ubuntu 14.04
After a long day I managed to get to the bottom of what I believe is a SSL/TLS cipher negotiation issue with a server that doesn't support the latest and greatest versions.
Stack:
Ubuntu 14.04 fully patched
OpenSSL 1.0.1f 6 Jan 2014
irb…

Thiago Figueiro
- 410
- 5
- 15
2
votes
2 answers
Error Converting Curl Request to Net::HTTP
I am trying to translate a curl request to ruby. I don't understand why this works:
curl -H "Content-Type: application/json" -X POST -d '{"username":"foo","password":"bar"}' https://xxxxxxxx.ws/authenticate
while this doesn't:
uri =…

masciugo
- 1,113
- 11
- 19