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
0
votes
1 answer

Rails 3 EachValidator for URLs

I want to create an EachValidator that I can use to test the validity of a given URL. Basically I would like to first test if it matches a URL format. If it appears to be a URL then use Net::HTTP to try and resolve the URL (including following…
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
0
votes
1 answer

Passing encoded URL query param using RestClient in Ruby giving incorrect result

I am trying to access a private API endpoint that accepts a phone number, including the country code, in the URL query parameters. Because the phone number has to include the "+", the phone number has to be encoded (i.e. the '+' becomes '%2B') When…
Hawkeye001
  • 791
  • 2
  • 11
  • 25
0
votes
2 answers

How to preserve custom headers case in ruby 2.6.5

I am able to access api when try wit curl cmd, but same not able to access with net/http, I did the string patch as per this link Preserving case in HTTP headers with Ruby's Net:HTTP and it was working well with ruby 2.2.4, but recently we migrated…
0
votes
1 answer

Where Can I Learn More about Net::HTTP Methods?

Can someone point me to good resource for Net::HTTP? I'm trying to understand why certain code functions the way it does. For example: def url_check(domain) parsed = URI.parse(domain).host check = Net::HTTP.new(parsed).head('/').kind_of?…
D. Simpson
  • 1,882
  • 17
  • 32
0
votes
1 answer

Proper way to upload a doc to FSCrawler for indexing in Elasticsearch

I'm prototyping a Rails application to upload documents to FSCrawler (running the REST interface), to incorporate into an Elasticsearch index. Using their example, this works: response = `curl -F "file=@#{params[:document][:upload].tempfile.path}"…
David Krider
  • 886
  • 12
  • 27
0
votes
1 answer

How use SOAP without Ruby

I am using Savon and it's working. My WSDL is:
0
votes
2 answers

Is there a way to check for invalid query parameters in an HTTP request?

I am building a Go DELETE REST endpoint. This request requires a set of query parameters which filters what objects to delete. for eg. https://endpoint.blah.com/users?userId=7&age=24 As of now, if somebody sends a request…
jazz
  • 27
  • 1
  • 10
0
votes
2 answers

How To change a URI object's path attribute?

I want to call an API using only slightly different URIs. This code snippet does what I want, but I want to know if there is a more efficient way to do it. require 'net/http' require 'json' # These URIs differ only in the path orders =…
0
votes
2 answers

js.erb rendering only the ruby code, not the js

Edit: I solved the problem myself - see below I have a form where I upload images using the add_picture_to_project_path route included in my projects_controller.rb. This method is exectuing the file upload in the model and then returning some Json…
0
votes
1 answer

Ruby Net:Http get request gives different response than with Browser

I am trying to fetch from API server using Net::HTTP. puts "#{uri}".green response = Net::HTTP.new('glassdoor.com').start { |http| # always proxy via your.proxy.addr:8080 response = http.get(uri, {'Accept' => 'application/json'}) puts "Res…
Hairi
  • 3,318
  • 2
  • 29
  • 68
0
votes
1 answer

duckduckgo.com to get the first N results for the specified phrase, using Net::HTTP ruby

I am trying to parse results from duckduckgo search with Net::HTTP and store the links of the results of the array. However the result comes as a string. Any idea how get it any other type of data back as result or how to get the links from the…
0
votes
1 answer

Fetch urls prefixed with username:password@

I am using net-http-persistent gem to fetch pages. It works perfectly fine for most of the cases. But, recently I noted that it returns 401 for urls prefixed with username:password@ e.g. https://username:password@somesite.com. If i try other options…
Mohsin Sethi
  • 803
  • 4
  • 16
0
votes
1 answer

Convert Hash to specific string format in ruby

I would like to convert a hash: {"key1"=>"value1", "key2"=>"value2"} into a string which looks like this: '[{"key1" : "value1","key2" : "value2"}]' Background: I'm making an API call from my rails Controller. The curl equivalent of this request is…
Manitude
  • 100
  • 7
0
votes
1 answer

Net HTTP Get request with content type, basic auth and params (https)

I’m new to NET HTTP and Ruby on Rails and I want to use some Get Request to take some data from a website. There isn’t much help on this topic online. Is it possible if someone guide me in the right direction. Other info : The website I’m calling to…
0
votes
1 answer

How to use "Net::http" in Coro?

Got stuck on using Net::HTTP when i create a Net::HTTP object it initialize with "IO::Socket::IP". how can i change default socket without hard-coding? I would like to change it to IO::Socket::INET. So if i hard-code socket, it works. But when i'm…