EOF error using net/https
-------------------------

                 Key: JRUBY-1159
                 URL: http://jira.codehaus.org/browse/JRUBY-1159
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.0RC3
         Environment: Windows XP and Vista.  Also observed on Mac OS X.
Windows JDK is jdk1.5.0_09
            Reporter: Eric Ching


This is with jruby-1.0 relase. (wasn't in the drop-down in 'Affects Version/s:'

I am running the following code (from RESTful web services book by O'Reilly):

require 'rubygems'
require 'open-uri'
require 'rexml/document'

def print_my_recent_bookmarks(username, password)
response = open('https://api.del.icio.us/v1/posts/recent', 
:http_basic_authentication => [username, password])
xml = response.read
document = REXML::Document.new(xml)
REXML::XPath.each(document, "/posts/post") do |e|
puts "#{e.attributes['description']}: #{e.attributes['href']}"
end
end

username, password = ARGV
unless username and password
puts "Usage: #{$0} [username] [password]"
exit
end
print_my_recent_bookmarks(username, password)

=================================
and get the following pretty much every run:

C:/lang/jruby-1.0/lib/ruby/1.8/net/protocol.rb:120:in `readuntil': End of file 
reached (EOF
Error)
       from C:/lang/jruby-1.0/lib/ruby/1.8/net/protocol.rb:126:in `readline'
       from C:/lang/jruby-1.0/lib/ruby/1.8/net/http.rb:2224:in `read_chunked'
       from C:/lang/jruby-1.0/lib/ruby/1.8/net/http.rb:2204:in `read_body_0'
       from C:/lang/jruby-1.0/lib/ruby/1.8/net/http.rb:2170:in `read_body'
       from C:/lang/jruby-1.0/lib/ruby/1.8/open-uri.rb:272:in `open_http'
       from C:/lang/jruby-1.0/lib/ruby/1.8/open-uri.rb:626:in `request'
       from C:/lang/jruby-1.0/lib/ruby/1.8/open-uri.rb:273:in `reading_body'
       from C:/lang/jruby-1.0/lib/ruby/1.8/net/http.rb:1051:in `request'
        ... 9 levels...
       from C:/lang/jruby-1.0/lib/ruby/1.8/open-uri.rb:30:in `open'
       from delicio.rb:6:in `print_my_recent_bookmarks'
       from delicio.rb:20

To get the sample even to work in C ruby I had to change http.verify_mode = 
OpenSSL::SSL::VERIFY_PEER to http.verify_mode = OpenSSL::SSL::VERIFY_NONE in 
open-uri.rb.  Once I did that it works everytime in C ruby, but in jruby I am 
not having such luck.  However,it has worked twice.  

I am getting the same thing in a non-uri version:

require 'net/https'
require "rexml/document"

resp = href = "";
begin      
  http = Net::HTTP.new("api.del.icio.us", 443)
  http.use_ssl = true
  http.start do |http|
    req = Net::HTTP::Get.new("/v1/posts/recent")
    req.basic_auth("myuser", "mypass")
    response = http.request(req)
    resp = response.body
  end     
  #  XML Document
  doc = REXML::Document.new(resp)    
  REXML::XPath.each(doc, "/posts/post") do |e|
        puts "#{e.attributes['description']}: #{e.attributes['href']}"
  end
  
rescue SocketError
  raise "Host " + host + " nicht erreichbar"
rescue REXML::ParseException => e
  print "error parsing XML " + e.to_s
end

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to