Class: Raptor::Reactor::Http1IO

Inherits:
ConnectionIO show all
Defined in:
lib/raptor/reactor.rb,
sig/generated/raptor/reactor.rbs

Overview

Tracks reactor-owned I/O state for an HTTP/1.x detached response.

Instance Attribute Summary collapse

Attributes inherited from ConnectionIO

#closing, #monitor, #offset, #output, #reading, #timeout, #wait

Instance Method Summary collapse

Constructor Details

#initialize(body, state) ⇒ Http1IO

Creates I/O state for an HTTP/1.x detached response.

Parameters:

  • body (DetachedBody) —

    the response body

  • state (Hash) —

    connection state restored after the response finishes, including bytes the client pipelined after the request



124
125
126
127
128
129
130
131
132
# File 'lib/raptor/reactor.rb', line 124

def initialize(body, state)
  super()
  @body = body
  @state = state
  @budget = DetachedBody::Budget.new(DETACHED_CONNECTION_BUFFER_SIZE)
  @input = String.new(state[:pipelined] || "", encoding: Encoding::ASCII_8BIT)
  @reading = true
  @finishing = false
end

Instance Attribute Details

#body ⇒ DetachedBody?

: DetachedBody?

Returns:



111
112
113
# File 'lib/raptor/reactor.rb', line 111

def body
  @body
end

#budget ⇒ DetachedBody::Budget (readonly)

: DetachedBody::Budget



113
114
115
# File 'lib/raptor/reactor.rb', line 113

def budget
  @budget
end

#finishing ⇒ Boolean

: bool

Returns:

  • (Boolean)


112
113
114
# File 'lib/raptor/reactor.rb', line 112

def finishing
  @finishing
end

#input ⇒ String (readonly)

: String

Returns:

  • (String)


114
115
116
# File 'lib/raptor/reactor.rb', line 114

def input
  @input
end

#state ⇒ Hash[Symbol, untyped] (readonly)

: Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


115
116
117
# File 'lib/raptor/reactor.rb', line 115

def state
  @state
end

Instance Method Details

#empty? ⇒ Boolean

Returns whether the connection has no output or detached body remaining.

Returns:

  • (Boolean)


139
140
141
# File 'lib/raptor/reactor.rb', line 139

def empty?
  super && !body
end