Skip to content

Commit

Permalink
client.rb - remove JRuby specific 'finish' code (#2412)
Browse files Browse the repository at this point in the history
Remove JRuby specific methods:
 #jruby_start_try_to_finish
 #eagerly_finish
  • Loading branch information
MSP-Greg committed Oct 6, 2020
1 parent 9ca9dde commit 8f9396f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 58 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -7,6 +7,7 @@
* Cleanup daemonization in rc.d script (#2409)

* Refactor
* client.rb - remove JRuby specific 'finish' code (#2412)
* Consolidate fast_write calls in Server, extract early_hints assembly (#2405)
* Remove upstart from docs (#2408)
* Consolidate option handling in Server, Server small refactors, doc changes (#2389)
Expand Down
63 changes: 5 additions & 58 deletions lib/puma/client.rb
Expand Up @@ -188,64 +188,11 @@ def try_to_finish
false
end

if IS_JRUBY
def jruby_start_try_to_finish
return read_body unless @read_header

begin
data = @io.sysread_nonblock(CHUNK_SIZE)
rescue OpenSSL::SSL::SSLError => e
return false if e.kind_of? IO::WaitReadable
raise e
end

# No data means a closed socket
unless data
@buffer = nil
set_ready
raise EOFError
end

if @buffer
@buffer << data
else
@buffer = data
end

@parsed_bytes = @parser.execute(@env, @buffer, @parsed_bytes)

if @parser.finished?
return setup_body
elsif @parsed_bytes >= MAX_HEADER
raise HttpParserError,
"HEADER is longer than allowed, aborting client early."
end

false
end

def eagerly_finish
return true if @ready

if @io.kind_of? OpenSSL::SSL::SSLSocket
return true if jruby_start_try_to_finish
end

return false unless IO.select([@to_io], nil, nil, 0)
try_to_finish
end

else

def eagerly_finish
return true if @ready
return false unless IO.select([@to_io], nil, nil, 0)
try_to_finish
end

# For documentation, see https://github.com/puma/puma/issues/1754
send(:alias_method, :jruby_eagerly_finish, :eagerly_finish)
end # IS_JRUBY
def eagerly_finish
return true if @ready
return false unless IO.select([@to_io], nil, nil, 0)
try_to_finish
end

def finish(timeout)
return true if @ready
Expand Down

0 comments on commit 8f9396f

Please sign in to comment.