Accessing SOS with Basic Authentication - Ruby

Posted by Linda Derezinski Mon, 23 Oct 2006 13:26:00 GMT

Basic authentication in Ruby example.

This is using Ruby 1.8.4 which may be installed:

Windows: http://rubyforge.org/frs/?group_id=167

OSX: http://hivelogic.com/articles/2005/12/01/rubyrailslighttpdmysqltiger

Example XML to pass to the SOS is found http://eo1.geobliki.com/sosdemo

post_it(xml)


 def post_it( xml, user = "bob", pass = "test")
    url = URI.parse('http://eo1.geobliki.com/sos')
    req = Net::HTTP::Post.new(url.path)
    req.basic_auth(user, pass)
    req['Content-Type'] = "text/xml"
    req.body = xml
    @response = Net::HTTP.start(url.host, url.port){|http|
      http.request(req)
    }
    puts @response.body     

  end
Comments

Leave a comment

Comments