module Coolio
Constants
- DEFAULT_BACKLOG
- VERSION
Public Class Methods
inspect()
click to toggle source
# File lib/cool.io.rb, line 26 def self.inspect "Cool.io" end
version()
click to toggle source
# File lib/cool.io/version.rb, line 4 def self.version VERSION end
Public Instance Methods
parse_chunk_header()
click to toggle source
# File lib/cool.io/http_client.rb, line 342 def parse_chunk_header return false unless parse_header(@chunk_header) @bytes_remaining = @chunk_header.chunk_size @chunk_header = HttpChunkHeader.new @state = @bytes_remaining > 0 ? :chunk_body : :response_footer true end
parse_header(header)
click to toggle source
# File lib/cool.io/http_client.rb, line 301 def parse_header(header) return false if @data.empty? begin @parser_nbytes = @parser.execute(header, @data.to_str, @parser_nbytes) rescue Coolio::HttpClientParserError on_error "invalid HTTP format, parsing fails" @state = :invalid end return false unless @parser.finished? # Clear parsed data from the buffer @data.read(@parser_nbytes) @parser.reset @parser_nbytes = 0 true end
parse_response_header()
click to toggle source
# File lib/cool.io/http_client.rb, line 321 def parse_response_header return false unless parse_header(@response_header) unless @response_header.http_status and @response_header.http_reason on_error "no HTTP response" @state = :invalid return false end on_response_header(@response_header) if @response_header.chunked_encoding? @state = :chunk_header else @state = :body @bytes_remaining = @response_header.content_length end true end
process_body()
click to toggle source
# File lib/cool.io/http_client.rb, line 398 def process_body if @bytes_remaining.nil? on_body_data @data.read return false end if @bytes_remaining.zero? on_request_complete @state = :finished return false end if @data.size < @bytes_remaining @bytes_remaining -= @data.size on_body_data @data.read return false end on_body_data @data.read(@bytes_remaining) @bytes_remaining = 0 if @data.empty? on_request_complete @state = :finished else on_error "garbage at end of body" @state = :invalid end false end
process_chunk_body()
click to toggle source
# File lib/cool.io/http_client.rb, line 352 def process_chunk_body if @data.size < @bytes_remaining @bytes_remaining -= @data.size on_body_data @data.read return false end on_body_data @data.read(@bytes_remaining) @bytes_remaining = 0 @state = :chunk_footer true end