Sha256: a54d4d51c6de2087ddc15ca437bcdf21006fccfa3a3fbc365fec6661273e82ef
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. require "protocol/http1" require_relative "request" require_relative "response" module Async module HTTP module Protocol module HTTP1 class Connection < ::Protocol::HTTP1::Connection def initialize(stream, version) super(stream) @version = version end def to_s "\#<#{self.class} negotiated #{@version}, #{@state}>" end def as_json(...) to_s end def to_json(...) as_json.to_json(...) end attr :version def http1? true end def http2? false end def read_line? @stream.read_until(CRLF) rescue => error # Bascially, any error will cause the connection to be closed: return nil end def read_line @stream.read_until(CRLF) or raise EOFError, "Could not read line!" end def peer @stream.io end attr :count def concurrency 1 end # Can we use this connection to make requests? def viable? self.idle? && @stream&.readable? end def reusable? @persistent && @stream && !@stream.closed? end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
async-http-0.81.0 | lib/async/http/protocol/http1/connection.rb |
async-http-0.80.1 | lib/async/http/protocol/http1/connection.rb |