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: convert curl command into Ruby net/http request

I'd like to convert this command line curl command into a Ruby net/http request: curl -u user:pword --insecure -XGET "https://192.168.10.10:3000/_search/template?pretty=true" -H 'Content-Type:application/json'…
Sandra Cieseck
  • 311
  • 1
  • 10
3
votes
0 answers

open_timeout and read_timeout not working

So I have a script that is going to gather some information about some domain names, and in some cases those domain names aren't even registered anymore, and their IP addresses cannot be resolved. When this happens, I can expect the following error…
LewlSauce
  • 5,326
  • 8
  • 44
  • 91
3
votes
0 answers

Apple Push Notification suddenly started to throw an error: Socket was remotely closed

I use the following code to send notification through the apple push notification api. It worked well until a few days ago when it started throwing an error: Socket was remotely closed This is the code that I'm using: p8key = "*****" private_key =…
3
votes
1 answer

http override http header code in golang while there is an error in json encoding

consider this scenario! after successful execution of a http request, what if there is an error while performing json encoding, how to override the header code func writeResp(w http.ResponseWriter, code int, data interface{}) { …
3
votes
0 answers

Post Request from client With Proper Headers Always return 401- UnAuthorized

Am a newbie to ruby. I am trying to invoke a REST API from ruby code. I have tried the code with both as standalone ruby code and inside a application using sinatra. But am facing same issue every where. Below are the options I have tried. My Code…
balaaagi
  • 502
  • 11
  • 21
3
votes
1 answer

Bad chunk-size in HTTP response: Net/HTTP/Methods.pm line 542

Questions that pose a similar problem: Issues with LWP when using HTTP/1.1: bad chunk-size, truncated responses. I am using the Perl module WWW::Mechanize to scrape web sites. As far as I understand, WWW::Mechanize uses the Net::HTTP module to…
Athithyaa
  • 33
  • 1
  • 6
3
votes
3 answers

Missing query parameters on x-www-form-urlencoded POST request and net/http

I have a post request with headers and query parameters that I want to fire with net/http. The request returns 200 but the response body says: {\"error\":\"invalid_request\",\"error_description\":\"Required query parameter 'grant_type'…
user4216977
3
votes
1 answer

Ruby Net::HTTP::Post submit form

I'm working on creating a website scraper. There is a form used to change the current page. This is the way that I am submitting the form for the POST request, but it seems to be fetching the same page over and over again. Here is some sample…
Zack Herbert
  • 942
  • 1
  • 16
  • 39
3
votes
1 answer

How do I set TCPSocket attributes for only a method and not globally?

I'm using Rails 4.2.7 with Ruby 2.3.0. I have this code for getting a web page through a SOCKS Proxy require "resolv-replace.rb" require 'open-uri' require 'uri' require "socksify" require 'socksify/http' ... def…
Dave
  • 15,639
  • 133
  • 442
  • 830
3
votes
1 answer

Ruby Net::HTTP using SSL

I have a very simple API, that I would like to make a POST to using ruby and NOT using a GEM just the built in libraries net/http, uri, and openssl if needed. Anyway, I am using the code below to make a very simple POST request but am getting some…
gregwinn
  • 941
  • 1
  • 9
  • 16
3
votes
1 answer

Ruby Net::HTTP execution expired

Using Net::HTTP, I periodically find that the code below rescues from StandardError with a message of "execution expired", despite the fact that the web server logs from the accessed URL show the corresponding response was sent quickly. When the…
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
3
votes
1 answer

use_ssl value changed, but session already started when trying to make https request

I’m using Rails 4.2.7 and this code for making a Net::Http get request req = Net::HTTP::Get.new(url) if !headers.nil? headers.each do |k, v| req[k] = v end end res = Net::HTTP.new(uri.host, uri.port).start do…
Dave
  • 15,639
  • 133
  • 442
  • 830
3
votes
1 answer

Net::HTTP – Flush or Close

I've written a consumer for a payment API. My code simply issues a POST request and gets a response from the API. I've implemented that with Net::HTTP, here are the relevant lines of code: http = Net::HTTP.new(uri.host, 443) http.use_ssl =…
svoop
  • 3,318
  • 1
  • 23
  • 41
3
votes
2 answers

Using Ruby's Net/HTTP module, can I ever send raw JSON data?

I've been doing a lot of research on the topic of sending JSON data through Ruby HTTP requests, compared to sending data and requests through Fiddler. My primary goal is to find a way to send a nested hash of data in an HTTP request using Ruby. In…
Max
  • 808
  • 11
  • 25
3
votes
2 answers

how to make a copy of response of http.Get(url) request in Golang

I'm trying to use resp, err := http.Get(url) command to write the response to file as well as use the same response to extract links. After I write the content to a file using resp.Write(f), I cannot use resp.Body for another purpose (for the…
L.fole
  • 687
  • 3
  • 12
  • 19