"end of file" error for "net/https"

Hi, I have written following code:- It is working fine for http protocol. But whenever I am doing for https I getting an error "end of file reached". Can anyone tell me what is wrong with the code?

def email_to_friend     require 'net/http'     require "net/https"     require 'uri' #res = Net::HTTP.post_form(URI.parse('http://www.test.com/‘),{'q'=>'ruby'})   res = Net::HTTP.post_form(URI.parse('https://product-search.api.cj.com/v2/product-search’),       {'q'=>'ruby'})     puts res.body end

Thanks, Tushar

Hi, I have written following code:- It is working fine for http protocol. But whenever I am doing for https I getting an error "end of file reached". Can anyone tell me what is wrong with the code?

Doesn't look like post_form handles https at all. It's just a convenience method - you should be able to write an https friendly version easily

Fred

Not altogether sure what problem you're running into, but http://github.com/jnunemaker/httparty has simplified a lot of my HTTP code.

require 'httparty' response = HTTParty.post("https://product-search.api.cj.com/v2/product-search", :query => {:q => 'ruby}) puts response.body

Sometimes server or connection errors may inadvertently throw an "end of file reached".