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
5
votes
1 answer
How to create a tls client with ca certificates in GO?
I want to create a tls client using the net/http in GO how can I create it given the ca certificates?
user6638302
5
votes
1 answer
POST request to HTTPS using Net::HTTP
This POST request using Ajax works perfectly:
var token = "my_token";
function sendTextMessage(sender, text) {
$.post('https://graph.facebook.com/v2.6/me/messages?',
{ recipient: {id: sender},
message: {text:text},
access_token:…

Graham Slick
- 6,692
- 9
- 51
- 87
5
votes
2 answers
Ruby https with ca certification does not work while it worked with curl
In ruby, I try to do a ssl connection to a nginx server I setup locally, with an auto-signed certificate. My code is :
require "net/http"
require "net/https"
require "openssl"
require "uri"
require "pp"
request = Net::HTTP::Get.new("/")
response =…

GPif
- 543
- 2
- 6
- 22
5
votes
1 answer
Net::HTTP Start vs New
Ruby Version: 1.9.3
http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net.html
The documentation states that "If you wish to re-use a connection across multiple HTTP requests without automatically closing it you can use ::new instead of…

kaiser
- 51
- 1
- 4
5
votes
1 answer
How can I use Net::Http to download a file with UTF-8 characters in it?
I have an application where users can upload text-based files (xml, csv, txt) that are persisted to S3. Some of these files are pretty big. There are a variety of operations that need to be performed on the data in these files, so rather than read…

RubyRedGrapefruit
- 12,066
- 16
- 92
- 193
5
votes
1 answer
API call using Net::HTTP throwing Net::HTTPBadResponse error
I am working on rails environment. I am using Net::HTTP module for calling an external API and getting the response. This is working fine in my local host. But in staging it throwing an Net::HTTPBadResponse error. My staging is SSL enabled. This is…

apr
- 676
- 1
- 9
- 21
5
votes
2 answers
How to send multiple of the same key/parameter via POST?
If I had to send a bunch of post parameters along an HTTP request, all with the same name, how do I construct the data object to post?
Picture a form with some check boxes, they all have the same name attribute but with different values (if they're…

Josh M.
- 26,437
- 24
- 119
- 200
5
votes
1 answer
Why do I get Net::HTTP "request path is empty" error?
I'm using Net::HTTP to make a HTTP request. I get the error "HTTP request path is empty", but I strongly feel that it is not. The code is below:
REQUEST_IP = "localhost"
REQUEST_PORT = "8081"
REQUEST_PATH = "myweb/rest"
def…

Pumpkin
- 1,993
- 3
- 26
- 32
4
votes
2 answers
How do I skip an iteration if an IF condition becomes true, and go to the first line of do .. end?
I wrote the following code:
require 'net/http'
require 'uri'
require 'IPAddr'
require 'timeout'
require 'Resolv'
require 'open-uri'
#puts "Origin IP:\n\n"
#originip = gets()
(IPAddr.new("209.85.175.120")..IPAddr.new("209.85.175.150")).each do…

Akash Panchal
- 205
- 1
- 6
- 20
4
votes
1 answer
Failed to open TCP connection to localhost:3101 - Rails / Docker
I'm trying to ping one of our Rails Microservices (handles emails) from our app, and I'm getting the title error.
Our microservice is running in docker on localhost:3101, whilst our app is on localhost:3000 on docker also - I've pinged it with…

s89_
- 1,533
- 3
- 25
- 40
4
votes
2 answers
How do I set use_ssl param when running a web request through a proxy?
I’m using Rails 4.2.7. How do I set the “use_ssl” parameter when sending a web request through a proxy? I have this
res1 = Net::HTTP.SOCKSProxy(TCPSocket::socks_server, TCPSocket::socks_port).start(uri.host, uri.port) do |http|
…

Dave
- 15,639
- 133
- 442
- 830
4
votes
2 answers
how do I include a header in an http request in ruby
Have the below code working:
uri = URI.parse("http://www.ncdc.noaa.gov/cdo-web/api/v2/datasets/")
response = Net::HTTP.get_response(uri)
Now I also need to pass a header with this token hash in it:
token: "fjhKJFSDHKJHjfgsdfdsljh"
I cannot find…

JPB
- 53
- 1
- 4
4
votes
0 answers
How to connect to an xml/soap web service via SSL with mutual auth?
I'm trying to consume a web service with a certificate, sending a XML/SOAP, via SSL with mutual authentication. I've tried savon and net/http, but I'm stopped with the same error:
SSL_CTX_use_PrivateKey: key values mismatch…

Henrique Navarro Marçulo
- 543
- 6
- 21
4
votes
0 answers
How to reuse connection across multiple HTTP requests with Net::HTTP?
The documentation says:
If you wish to re-use a connection across multiple HTTP requests without automatically closing it you can use ::new instead of ::start. request will automatically open a connection to the server if one is not currently open.…

x-yuri
- 16,722
- 15
- 114
- 161
4
votes
0 answers
override http.ssl_version to TLSv1 not working
I am trying to force Ruby's net/http and net/https to use TLSv1 instead of SSLv3.
I have read a lot of articles which say that you can do this with one of:
http.ssl_version = :TLSv1
http.ssl_version = "TLSv1"
but neither seems to work, I keep on…

opensource-developer
- 2,826
- 4
- 38
- 88