net-http

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

扶醉桌前 提交于 2020-01-02 10:46:08
问题 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 still had no luck. I can post the httpd.conf should it be needed. This is the code: BOUNDARY = "AaB03xZZZZZZ11322321111XSDW" uri = URI.parse("http://localhost/dropbox/") file = "/tmp/KEYS.txt" http = Net::HTTP.new(uri.host, uri.port) request = Net:

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

喜你入骨 提交于 2020-01-02 10:45:59
问题 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 still had no luck. I can post the httpd.conf should it be needed. This is the code: BOUNDARY = "AaB03xZZZZZZ11322321111XSDW" uri = URI.parse("http://localhost/dropbox/") file = "/tmp/KEYS.txt" http = Net::HTTP.new(uri.host, uri.port) request = Net:

How to use a custom OpenSSL engine for Net::HTTP

£可爱£侵袭症+ 提交于 2019-12-24 16:13:49
问题 I am trying to use a custom OpenSSL engine for crypto operations required for client certificate authentication. Currently Net::HTTP lets us pass only the cert and key which will be used for the client authentication. We are moving all private keys to HSM ("Hardware Security Module") so instead of the default OpenSSL engine we want to plug-in a custom OpenSSL engine. The custom OpenSSL engine will perform private key signing operations using HSM. Current with the default engine we have code

Where openssl searches for default certificates?

好久不见. 提交于 2019-12-24 12:25:55
问题 Today I faced a problem making https request with ruby under windows : C:\Users\Yuri\_>type 2.rb require 'net/http' Net::HTTP.get URI 'https://google.com' C:\Users\Yuri\_>2.rb c:/Users/Yuri/programs/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) from c:/Users/Yuri/programs/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:918:in `block in connect' from c:/Users/Yuri

use ruby to get content length of URLs

岁酱吖の 提交于 2019-12-24 00:53:05
问题 I am trying to write a ruby script that gets some details about files on a website using net/http . My code looks like this: require 'open-uri' require 'net/http' url = URI.parse asset res = Net::HTTP.start(url.host, url.port) {|http| http.get(asset) } headers = res.to_hash p headers I would like to get two pieces of information from this request: the total length of the content inflated, and (as appropriate) the length of the content deflated. Sometimes, the headers will include a content

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

会有一股神秘感。 提交于 2019-12-24 00:08:54
问题 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 Fiddler, you can specify a JSON in the request body and add the header "Content-Type: application/json". In Ruby, using Net/HTTP, I'd like to do the same thing if it's possible. I have a hunch that it isn't possible, because the only way to add JSON

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ONLY WHEN PROXYING

大憨熊 提交于 2019-12-23 12:43:24
问题 This post nearly duplicates a number of other posts, including 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 and SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed, but with one key difference: the "certificate verify failed" error only happens when proxied via an SSL proxy (Charles), and only in the latest version of Ruby. Specifically, this (non

Capybara increase max allowed page load time

半城伤御伤魂 提交于 2019-12-23 09:32:08
问题 I have a page that sometimes loads in over a minute. Assume this is the expected behavior and wont change. In these cases, I get Net::ReadTimeout . Note that this is after navigating to a page by clicking a button on the previous page, not an ajax request. Therefore Capybara.using_wait_time doesn't help. I have tried a number of radical things (some of which I knew wouldn't work) like: Setting page.driver.browser.manage.timeouts 's implicit_wait , script_timeout and page_load . Looping

Adjusting timeouts for Nokogiri connections

主宰稳场 提交于 2019-12-22 18:37:32
问题 Why nokogiri waits for couple of secongs (3-5) when the server is busy and I'm requesting pages one by one, but when these request are in a loop, nokogiri does not wait and throws the timeout message. I'm using timeout block wrapping the request, but nokogiri does not wait for that time at all. Any suggested procedure on this? # this is a method from the eng class def get_page(url,page_type) begin timeout(10) do # Get a Nokogiri::HTML::Document for the page we’re interested in... @@doc =

Adjusting timeouts for Nokogiri connections

醉酒当歌 提交于 2019-12-22 18:37:00
问题 Why nokogiri waits for couple of secongs (3-5) when the server is busy and I'm requesting pages one by one, but when these request are in a loop, nokogiri does not wait and throws the timeout message. I'm using timeout block wrapping the request, but nokogiri does not wait for that time at all. Any suggested procedure on this? # this is a method from the eng class def get_page(url,page_type) begin timeout(10) do # Get a Nokogiri::HTML::Document for the page we’re interested in... @@doc =