summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-17 20:40:50 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-17 20:40:50 +0000
commitb2deafb27774ecf3c931294c5dd10e7fd1831aba (patch)
treeb20fdbecf52daaa0fc88b7455e5a76226196ca5d
parent92e4b1b06e10557e1cfce4962b55f4960f6ed5b5 (diff)
aamine
* lib/net/http.rb: Response#range_length was not debugged. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/net/http.rb28
2 files changed, 16 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 931519f..fe5a4ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Feb 18 05:46:03 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: Response#range_length was not debugged.
+
Sun Feb 18 00:09:50 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* win32/win32.c: fasten file I/O on mswin32/mingw32.
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 4c39bb7..402987c 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1004,21 +1004,17 @@ module Net
end
def range_length
- if @header.key? 'content-range' then
- m = %r<bytes\s+(\d+)-(\d+)/\d+>.match( @header['content-range'] )
- unless m then
- raise HTTPBadResponse, 'wrong Content-Range format'
- end
- l = m[2].to_i
- u = m[1].to_i
- if l > u then
- nil
- else
- u - l
- end
- else
- nil
- end
+ s = @header['content-range']
+ s or return nil
+
+ m = %r<bytes\s+(\d+)-(\d+)/(?:\d+|\*)>.match( s )
+ m or raise HTTPBadResponse, 'wrong Content-Range format'
+
+ low = m[1].to_i
+ up = m[2].to_i
+ return nil if low > up
+
+ up - low + 1
end
def stream_check
@@ -1035,7 +1031,7 @@ module Net
if block then
::Net::NetPrivate::ReadAdapter.new block
else
- dest or ''
+ dest || ''
end
end