Skip to content

Instantly share code, notes, and snippets.

@SaitoWu
Created August 23, 2012 07:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaitoWu/3433666 to your computer and use it in GitHub Desktop.
Save SaitoWu/3433666 to your computer and use it in GitHub Desktop.
ruby web server
# unicorn
# tee_input.rb 36L
@tmp = @len && @len <= @@client_body_buffer_size ?
StringIO.new("") : Unicorn::TmpIO.new
# Puma
# client.rb 106L
if remain > MAX_BODY
@body = Tempfile.new(Const::PUMA_TMP_BASE)
@body.binmode
else
# The body[0,0] trick is to get an empty string in the same
# encoding as body.
@body = StringIO.new body[0,0]
end
# Thin
# request.rb 76L
if @parser.finished? # Header finished, can only be some more body
body << data
else # Parse more header using the super parser
@data << data
raise InvalidRequest, 'Header longer than allowed' if @data.size > MAX_HEADER
@nparsed = @parser.execute(@env, @data, @nparsed)
# Transfert to a tempfile if body is very big
move_body_to_tempfile if @parser.finished? && content_length > MAX_BODY
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment