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
2
votes
2 answers

http request (using net http or RestClient) inside my rails controller

I have problem creating http request inside my controller action. I used net/http and RestClient but I can't get it to work on my local server url i.e http://localhost:3000/engine/do_process, I always get requesttimeout however It works with other…
2
votes
1 answer

net/http with proxy results in EOFError (end of file reached)

I'm trying to use NORD VPN proxy to make a request in ruby. The proxy is good, I've tested it successfully with curl as well as in a python script. However, I'm not able to make it work in ruby and I suspect it has to do with the odd port (89) used…
lyf1n
  • 81
  • 1
  • 5
2
votes
1 answer

Passing array of id's as query parameter of net/http

I want to do a GET request like that using the standard Ruby client net/http: stores/?ids=2,24,13 I'm trying to do it this way, where store_ids is an array of ids, but it is not working. If I pass a single id as a param for ids, the response is…
McNulty007
  • 23
  • 2
2
votes
0 answers

Rails Net::HTTP form data with custom headers

I am trying to send a file through form_data and set the Content-Type header as the content type of the file (image/png, image/jpeg, etc.) instead of multipart/form-data. I have tried multiple ways, but here is my method: def fetch(url, body,…
2
votes
2 answers

Omniauth: Facebook callback kills dev server

I'm following the code here: http://railscasts.com/episodes/241-simple-omniauth?autoplay=true I'm on ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] and Rails 3.0.7 Basically, I have my own user model (no Devise/AuthLogic). I…
2
votes
0 answers

I am trying to test an REST Api client in Golang using mux and httptest

Here I am trying to write a test for a REST client, by writing the apiOutput into the http.ResponseWriter but I always receive {nil nil} as apiResponse. Can someone help me in pointing out the error ? func Test_Do(t *testing.T) { mux :=…
James Sapam
  • 16,036
  • 12
  • 50
  • 73
2
votes
1 answer

How do I retrieve the response.URL using Faraday gem?

I'm using Faraday to check for broken links, and I want to retrieve the response.URL of the links I'm querying, however, I am not able to find any documentation and examples to do so. I was able to do this on the front-end using Javascript's Fetch…
iamleftclick
  • 63
  • 1
  • 9
2
votes
1 answer

Ruby Net::HTTP passing headers through the creation of request

Maybe I'm just blind but many post about passing headers in Net::HTTP follows the lines of require 'net/http' uri = URI("http://www.ruby-lang.org") req = Net::HTTP::Get.new(uri) req['some_header'] = "some_val" res =…
2
votes
2 answers

Elegantly using Kernel#open for https via open-uri

After requiring open-uri, one can conveniently download and use files from the web via Kernel#open. However, trying to do this with https results in a root cert error, because ruby doesn't have all the root certs. This can be solved like this, but…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
2
votes
3 answers

Is there a way to set Content-type in multipart request with set_form method?

I need to set Content-type = "application/pdf" to a parameter of a request with the method "set_form" from net/http class but it always shows me Content-Type = "application/octet-stream". I already checked out the documentation for set_form but I…
Jose Fdez
  • 23
  • 1
  • 4
2
votes
1 answer

TypeError problem: no implicit conversion in Sinatra + JSON.parse

I'm trying to set up a web hook, following this GitHub tutorial require 'sinatra' require 'json' require 'net/http' require 'pp' set :port, 31415 # Descarga las diferencias hechas para un push post '/' do push = JSON.parse(request.body.read) …
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
2
votes
1 answer

Why does 'Net::HTTPUnknownResponse.kind_of? Net::HTTPResponse' return 'false'?

I am using library net/http, and am trying to check if a response is type Net::HTTPResponse. I tried: Net::HTTPUnknownResponse.kind_of? Net::HTTPResponse # => false What's wrong?
Montenegrodr
  • 1,597
  • 1
  • 16
  • 30
2
votes
0 answers

Send requests behind a company proxy using net/http in Ruby

I am working behind a company proxy and I set up a Dashboard using some frameworks. The Dashboard is running in a Docker container. The backend for requests against 3rd party components is handled by Ruby jobs. With one job I try to connect from my…
xFuture
  • 326
  • 1
  • 8
2
votes
1 answer

HTTParty integer in request headers

I need to POST to an API, which requires a header in the request called "Timestamp", whose value has to be an integer (current time from epoch as an integer). I tried to do this with HTTParty and with Net::HTTP as follows: response =…
Steve Q
  • 395
  • 5
  • 28
2
votes
1 answer

Where is the http-access.rb file?

In the ruby standard library there is a file called net/http.rb. Towards the top of the page there is a comment: # Copyright (c) 1999-2007 Yukihiro Matsumoto # Copyright (c) 1999-2007 Minero Aoki # Copyright (c) 2001 GOTOU Yuuzou # # Written and…
mbigras
  • 7,664
  • 11
  • 50
  • 111