Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2799
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: HTTP request, with headers, post data and SSL :( |
| Date | 2011-04-13 18:44 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <e3038966ef38586a68f36136a45c4063@ruby-forum.com> (permalink) |
| References | <cc8c045fb2e91f082249ef47f97aaec8@ruby-forum.com> |
Stuffe L. wrote in post #992584:
> Hello everyone
>
> I am new to ruby and have been struggeling with this http api thing. I
> need to do a request with certian request headers, certain post
> variables and SSL.
> I got it to work with SSL and the headers, but I just cant get it to
> work when i try to cenvert it to post. Very frustrating.
>
> Heres how far i got (this is without post, which i couldnt get to work):
>
> post_me = 'xml data'
>
> headers = {'Header' => 'Whatever'}
> uri = URI.parse("https://example.com")
> http = Net::HTTP.new(uri.host, uri.port)
> http.use_ssl = true
> http.verify_mode = OpenSSL::SSL::VERIFY_NONE
> response = http.post(uri.request_uri, get_string, headers)
>
> Any help very much apreciated
1) In that code get_string is undefined.
2) In that code there are no require statements requiring the necessary
libraries.
See if you can get this to work:
require 'net/http'
require 'net/https'
require 'uri'
url = URI.parse('https://www.some_host.com/some_path_to/page.htm')
http = Net::HTTP.new(url.host)
http.use_ssl = true
data = "a=1&b=2&c=3"
headers = {
'Cookie' => cookie,
'Referer' => 'http://profil.wp.pl/login.html',
'Content-Type' => 'application/x-www-form-urlencoded'
}
resp = http.post(url.path, data, headers)
puts resp.body
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
HTTP request, with headers, post data and SSL :( "Stuffe L." <stuffe.dk@gmail.com> - 2011-04-13 14:11 -0500
Re: HTTP request, with headers, post data and SSL :( Oscar Sosa <oscar.americo@gmail.com> - 2011-04-13 18:28 -0500
Re: HTTP request, with headers, post data and SSL :( 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-13 18:44 -0500
Re: HTTP request, with headers, post data and SSL :( "Stuffe L." <stuffe.dk@gmail.com> - 2011-04-14 03:33 -0500
Re: HTTP request, with headers, post data and SSL :( 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-14 12:56 -0500
csiph-web