OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server hello A

This is a problem at the server site. It looks like the server is exclusively accepting TLS 1.2 and does not show the usual behavior when the client requests something lesser (like downgrading or sending SSL alert) but instead just closes the connection. TLS 1.2 is not supported by OpenSSL 0.9.8 and additionally your code … Read more

Ruby – net/http – following redirects

To follow redirects, you can do something like this (taken from ruby-doc) Following Redirection require ‘net/http’ require ‘uri’ def fetch(uri_str, limit = 10) # You should choose better exception. raise ArgumentError, ‘HTTP redirect too deep’ if limit == 0 url = URI.parse(uri_str) req = Net::HTTP::Get.new(url.path, { ‘User-Agent’ => ‘Mozilla/5.0 (etc…)’ }) response = Net::HTTP.start(url.host, url.port, … Read more

Check Ruby HTTP response for success

For Net::HTTP, yes, checking the class of the response object is the way to do it. Using kind_of? (aliased also as is_a?) is a bit clearer (but functionally equivalent to using <): response.kind_of? Net::HTTPSuccess Calling value on response will also raise a Net::HTTPError if the status code was not a successful one (what a poorly … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)