1.9.1-p0 $B$N(B Net::HTTP#get $B$NBh(B 2 $B0z?t(B

zundae$B$H?=$7$^$9e(B

tDiarye$B$Ne(Bweather.rbe$B%W%i%0%$%s$re(Bruby-1.9.1e$B$GF0$/$h$&$K$7$h$&$H$7$F$$$Fe(B*1e$B!"e(B
ruby-1.9.1-p0e$B$Ne(BNet::HTTP#gete$B%a%=%C%I$,Bhe(B2e$B0z?t$Ke(Bnile$B$r<u$1<h$i$J$/$J$C$F$$e(B
e$B$k$3$H$K5$$E$-$^$7$?!#e(B

e$B6qBNE*$K$O!“e(Bzlibe$B$,e(Brequiree$B$G$-$?>l9g$Ke(Bnet/http.rbe$B$Ne(B809e$B9TL$Ge(B
undefined method `keys’ for nil:NilClass (NoMethodError)
e$B$H$J$j$^$9!#$$$C$]$&!”%j%U%!%l%s%9%^%K%e%"%ke(B
http://www.ruby-lang.org/ja/man/html/Net_HTTP.html#get
e$B$G$OBhe(B2e$B0z?t$Ke(Bnile$B$r5v$9$h$&$K8+$($^$9!#I,MW$G$7$?$i$I$A$i$+$NJQ99$r$*4j$$e(B
e$B$7$^$9!#e(B

e$B$J$*!"<j85$G$O!“2<5-$N$h$&$JJQ99$G%j%U%!%l%s%9%^%K%e%”%k$+$i4|BT$5$l$kF0e(B
e$B:n$K$J$C$?$H;W$$$^$9!#e(B(svn trunke$B$KBP$9$k:9J,$G$9!#e(B)

e$B0J>e!"$h$m$7$/$*4j$$$7$^$9!#e(B

*1 http://zunda.freeshell.org/d/20090210.html#p03

Index: lib/net/http.rb

— lib/net/http.rb (revision 22249)
+++ lib/net/http.rb (working copy)
@@ -806,6 +806,7 @@
def get(path, initheader = {}, dest = nil, &block) # :yield:
+body_segment+
res = nil
if HAVE_ZLIB

  •    initheader ||= {}
       unless  initheader.keys.any?{|k| k.downcase == 
    

“accept-encoding”}
initheader[“accept-encoding”] =
“gzip;q=1.0,deflate;q=0.6,identity;q=0.3”
@compression = true
Index: test/net/http/test_http.rb

— test/net/http/test_http.rb (revision 22249)
+++ test/net/http/test_http.rb (working copy)
@@ -24,6 +24,7 @@
def test_get
start {|http|
_test_get__get http

  •  _test_get__get_initheader http
     _test_get__iter http
     _test_get__chunked http
    

    }
    @@ -43,6 +44,18 @@
    assert_equal $test_net_http_data, res.body
    end

  • def _test_get__get_initheader(http)

  • assert_nothing_raised {

  •  res, body = http.get('/')
    
  • }

  • assert_nothing_raised {

  •  res, body = http.get('/', {})
    
  • }

  • assert_nothing_raised {

  •  res, body = http.get('/', nil)
    
  • }

  • end

  • def _test_get__iter(http)
    buf = ‘’
    res, body = http.get(‘/’) {|s| buf << s }