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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 17, 2:48 pm, Mike Disuza <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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> Thanks, > Tushar > -- > Posted viahttp://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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".
On May 17, 2010, at 9:48 AM, Mike Disuza 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?
>
> 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
--
Zach Moazeni
http://simplechatter.com
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.