Skip to content

Commit

Permalink
Merge pull request #247 from httprb/zanker/fixednil-parser
Browse files Browse the repository at this point in the history
Fixed exceptionless NIO handling for EOF
  • Loading branch information
zanker committed Aug 18, 2015
2 parents 54ee5d1 + 4bb29b6 commit 5e5c029
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.9.2 (2015-08-18)
* Fixed exceptionless NIO EOF handling. (@zanker)

## 0.9.1 (2015-08-14)

* Fix params special-chars escaping. See #246. (@ixti)
Expand Down
8 changes: 5 additions & 3 deletions lib/http/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ def read_more(size)
return if @parser.finished?

value = @socket.readpartial(size)
@parser << value unless value == :eof

nil
if value == :eof
:eof
elsif value
@parser << value
end
end
end
end
6 changes: 5 additions & 1 deletion lib/http/timeout/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def readpartial(size)

loop do
result = socket.read_nonblock(size, :exception => false)
break result unless result == :wait_readable
if result.nil?
return :eof
elsif result != :wait_readable
return result
end

IO.select([socket], nil, nil, time_left)
log_time
Expand Down
6 changes: 5 additions & 1 deletion lib/http/timeout/per_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def write(data)
def readpartial(size)
loop do
result = socket.read_nonblock(size, :exception => false)
break result unless result == :wait_readable
if result.nil?
return :eof
elsif result != :wait_readable
return result
end

unless IO.select([socket], nil, nil, read_timeout)
fail TimeoutError, "Read timed out after #{read_timeout} seconds"
Expand Down
2 changes: 1 addition & 1 deletion lib/http/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module HTTP
VERSION = "0.9.1".freeze
VERSION = "0.9.2".freeze
end

0 comments on commit 5e5c029

Please sign in to comment.