472,146 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Net::HTTP URI.parse

HI All,

i am new to ROR

i am writing Ruby code for calling API blogs

i have written ruby code for

creating a attachment xml by
Expand|Select|Wrap|Line Numbers
  1. require 'net/http'
  2. require 'uri'
  4. url = URI.parse('https://localhost:3000/api/attachment/create.xml')
  5. req = Net::HTTP::Post.new(url.path)
  6. req.basic_auth 'a', 'a'
  8. res = Net::HTTP.new(url.host, url.port).start {|http|
  9. http.request(req)}
  11. case res
  12.   when Net::HTTPSuccess, Net::HTTPRedirection
  13.     puts res.body
  14.   else
  15.     res.error!
  16. end
Actually this works fine wth http protocol,

My site is hosted in https protocol, can https protocol can be used in
the below format. if i try to convert this kind of URL i get a error

SocketError: getaddrinfo: Temporary failure in name resolution

plz help me in this
Jan 8 '11 #1
1 4555
3,503 Expert Mod 2GB
To parse an HTTPS connection, you are going to want to use:

Expand|Select|Wrap|Line Numbers
  1. require "net/https"
There is an example on this cheat sheet page.

There is also another example .


Jan 17 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Kevin Kenny | last post: by
3 posts views Thread by thomson | last post: by
4 posts views Thread by skOOb33 | last post: by
reply views Thread by Divyakumar Jain,SAP Netweaver consultant | last post: by
reply views Thread by Friso Wiskerke | last post: by
1 post views Thread by John Braham | last post: by
1 post views Thread by Morgan Cheng | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.