Questions tagged [net-http]

An HTTP client API for Ruby. Net::HTTP provides a rich library which can be used to build HTTP user-agents.

450 questions
3
votes
1 answer

Ruby Net::HTTP POST send data gzip compressed

I am using Net::HTTP::Post under JRUBY 1.9.2 to send data to a custom server (not a web server), that want the data to be gzipped compressed. How can I tell Net::HTTP::Post to gzip compress the data it is POSTING?
aaa90210
  • 11,295
  • 13
  • 51
  • 88
3
votes
0 answers

"End of file reached" error OR Zlib::BufError using HTTParty

I am experiencing two different errors - depending on whether I use Httparty in my Ruby app or I use it from the command line. URL I am trying to access:…
yas4891
  • 4,774
  • 3
  • 34
  • 55
3
votes
1 answer

ruby net/http `read_body': Net::HTTPOK#read_body called twice (IOError)

I'm getting read_body called twice (IOError) using the net/http library. I'm trying to download files and use http sessions efficiently. Looking for some help or advice to fix my issues. From my debug message it appears when I log the response code,…
3
votes
2 answers

Setting an HTTP Timeout in Ruby 1.9.3

I'm using Ruby 1.9.3 and need to GET a URL. I have this working with Net::HTTP, however, if the site is down, Net::HTTP ends up hanging. While searching the internet, I've seen many people faced similar problems, all with hacky solutions. However,…
SRobertJames
  • 8,210
  • 14
  • 60
  • 107
3
votes
2 answers

How do I get a redirected status code using NET:HTTP?

Similar to "getting the status code of a HTTP redirected page", but with NET::HTTP instead of curb I am making a GET request to a page that that will redirect: response =…
Mike Kovner
  • 31
  • 1
  • 3
3
votes
1 answer

Mechanize getting "Errno::ECONNRESET: Connection reset by peer - SSL_connect"

I'm unable to get Mechanize to load a page that used to work -- it's reliably failing with a Errno: ECONNRESET: Connection reset by peer - SSL_connect message. Any suggestions as to what I should try or details I should look at? (Please see "what…
fearless_fool
  • 33,645
  • 23
  • 135
  • 217
3
votes
2 answers

Rails 4 and Ruby 2 Net/HTTP SSL Request: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

This is nearly a duplicate of: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed but specific to a Rails 4 and Ruby 2 environment. I figure it is appropriate to make a new question because the solutions…
Michael Pell
  • 1,416
  • 1
  • 14
  • 17
3
votes
2 answers

Ruby Net::HTTP::Options does not allow response body

I am writing a script to test various web-services in ruby. To make http requests thus far I have been using Net::HTTP but today I realized I needed to make an OPTIONS request and retrieve some JSON from the response. Unfortunately ruby does not…
3
votes
0 answers

Errno::ECONNREFUSED: Connection refused - connect(2) with Net::HTTP

I have my one server connecting to my other server (on a different machine) using net::http. When I use curl, it works (on localhost): curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d…
JohnMerlino
  • 3,900
  • 4
  • 57
  • 89
3
votes
3 answers

Making HEAD request in Ruby

I am kind of new to ruby and from a python background I want to make a head request to a URL and check some information like if the file exists on the server and timestamp, etag etc.,I am not able to get this done in RUBY. In Python: import…
Krish
  • 467
  • 1
  • 6
  • 16
3
votes
1 answer

Uploading a file using ruby Net:HTTP API to a remote apache server failing with 409 Conflict

Below is a program to upload a file from local file system to a remote Apache server. The program ends with a 409 conflict error. Is there any advice what am I doing wrong? I turned DAV on in httpd.conf and gave all necessary permissions, but I…
MPK
  • 133
  • 2
  • 9
3
votes
2 answers

Ruby Mechanize, Nokogiri and Net::HTTP

I am using Net::HTTP for HTTP requests and getting a response back: uri = URI("http://www.example.com") http = Net::HTTP.start(uri.host, uri.port, proxy_host, proxy_port) request = Net::HTTP::Get.new uri.request_uri response = http.request request #…
HPC_wizard
  • 179
  • 3
  • 11
2
votes
1 answer

uncaught exception with net/http request wrapper in ruby

I have a script that calls the facebook test api to automate test account creation. At seemingly random interval, from either after 50 requests to 6000 requests, I get an exception that isn't caught. I'm at a loss for how to figure out what the…
ToneLoc
  • 27
  • 1
  • 5
2
votes
2 answers

get ebay time in rails

I've been looking around a bit for how to get the time off of ebay.. I don't want to use SAVON because... well it didn't work.. So I'm trying to use net/http, just to get the time. (for now) Here's what I got so far. def get_ebay_time require…
baash05
  • 4,394
  • 11
  • 59
  • 97
2
votes
2 answers

Why is Net::HTTP timing out when I try to access a Prawn Generated PDF?

I am using Prawn to generate a PDF from my controller, and when accessed directly at the url, it works flawlessly, I.E. localhost:3000/responses/1.pdf However, when I try to generate this file on the fly for inclusion in a Mailer, everything freezes…
Oranges13
  • 1,084
  • 1
  • 10
  • 33