Class: HTTP::Protocol::HTTP10::Connection

Inherits:
HTTP::Protocol::HTTP11::Connection show all
Defined in:
lib/http/protocol/http10/connection.rb

Constant Summary collapse

KEEP_ALIVE =
'keep-alive'.freeze
VERSION =
"HTTP/1.0".freeze

Constants inherited from HTTP::Protocol::HTTP11::Connection

HTTP::Protocol::HTTP11::Connection::CLOSE, HTTP::Protocol::HTTP11::Connection::CONNECT, HTTP::Protocol::HTTP11::Connection::CONNECTION, HTTP::Protocol::HTTP11::Connection::CRLF, HTTP::Protocol::HTTP11::Connection::HEAD, HTTP::Protocol::HTTP11::Connection::HOST

Instance Attribute Summary

Attributes inherited from HTTP::Protocol::HTTP11::Connection

#count, #persistent, #stream

Instance Method Summary collapse

Methods inherited from HTTP::Protocol::HTTP11::Connection

#close, #each_line, #hijack, #initialize, #read_body, #read_chunk, #read_chunked_body, #read_fixed_body, #read_headers, #read_line, #read_remainder_body, #read_request, #read_request_body, #read_response, #read_response_body, #read_tunnel_body, #write_body_and_close, #write_body_head, #write_chunk, #write_chunked_body, #write_empty_body, #write_fixed_length_body, #write_headers, #write_request, #write_response

Constructor Details

This class inherits a constructor from HTTP::Protocol::HTTP11::Connection

Instance Method Details

#persistent?(headers) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/http/protocol/http10/connection.rb', line 34

def persistent?(headers)
	if connection = headers[CONNECTION]
		return connection.include?(KEEP_ALIVE)
	else
		return false
	end
end

#versionObject



30
31
32
# File 'lib/http/protocol/http10/connection.rb', line 30

def version
	VERSION
end

#write_body(body, chunked = false) ⇒ Object



46
47
48
49
# File 'lib/http/protocol/http10/connection.rb', line 46

def write_body(body, chunked = false)
	# We don't support chunked encoding by default.
	super(body, chunked)
end

#write_persistent_headerObject



42
43
44
# File 'lib/http/protocol/http10/connection.rb', line 42

def write_persistent_header
	@stream.write("connection: keep-alive\r\n") if @persistent
end