Error when checking user status

I receive status code when I paste url in browser, but when I try to do
status = Net::HTTP.get_response(URI.parse("https://mysite.chargevault.com/status?key=key&code=code")).body

I receive this error:

Net::HTTPBadResponse: wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"

/usr/ruby1.9.2/lib/ruby/1.9.1/net/http.rb:2221:in `read_status_line'
/usr/ruby1.9.2/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
/usr/ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
/usr/ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1177:in `request'
  1. Hi Ildar -- Can you tell what the raw response is?

  2. I guess that bit of code was untested. It turns out to be much more involved because of the ssl:

    uri = URI.parse("https://yoursite.chargevault.com/status?key=a1b2c3d4e6&code=yourcustomercode")
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    request = Net::HTTP::Get.new(uri.request_uri)
    status = http.request(request).body
    
  3. Problem solved,
    Thank you!

  4. Marc Guyer closed this discussion on 20 May, 2011 03:27 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions