"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

On May 17, 2:48 pm, Mike D. [email protected] wrote:

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
GitHub - jnunemaker/httparty: 🎉 Makes http fun again! 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”.

On May 17, 2010, at 9:48 AM, Mike D. wrote:

#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


Zach M.