Forum: Ruby on Rails nil.strip error While trying to post xml data over https.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex W. (Guest)
on 2006-05-03 04:46
I am trying to subit some xml data over https to access an API.  My code
so far seems to generate a very non-helpful error in the guts of the
net/http library.  This code produces a NoMethodError for nil.strip"

    require 'net/http'
    require 'net/https'
    require 'uri'

    url = URI.parse('www.beautifulpixel.com/index.html')
    connection = Net::HTTP.new(url.host, 443)
    connection.use_ssl = true

    #This is the line that causes an error
    response = connection.request(Net::HTTP::Post.new(url.path,
request_body))


#The error occured while evaluating nil.strip
#        from c:/ruby/lib/ruby/1.8/net/http.rb:1138:in
`initialize_http_header'
#        from c:/ruby/lib/ruby/1.8/net/http.rb:1136:in
`initialize_http_header'
#        from c:/ruby/lib/ruby/1.8/net/http.rb:1443:in `initialize'
#        from c:/ruby/lib/ruby/1.8/net/http.rb:1556:in `initialize'
#        from ./lib/ups_api.rb:74:in `initialize'
#        from (irb):13

What am I missing here?
Jean-François (Guest)
on 2006-05-03 21:06
(Received via mailing list)
2006/5/3, Alex W. <removed_email_address@domain.invalid>:
>     connection.use_ssl = true
>
>     #This is the line that causes an error
>     response = connection.request(Net::HTTP::Post.new(url.path,
> request_body))
>
> What am I missing here?

I guess that :

irb(main):001:0> require 'uri'
=> true
irb(main):002:0> URI.parse('www.beautifulpixel.com/index.html').host
=> nil
irb(main):003:0>
URI.parse('http://www.beautifulpixel.com/index.html').host
=> "www.beautifulpixel.com"
irb(main):004:0>

   -- Jean-François.
This topic is locked and can not be replied to.