Class: Thin::Response::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/thin/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(writer) ⇒ Stream

Returns a new instance of Stream.



5
6
7
8
9
# File 'lib/thin/response.rb', line 5

def initialize(writer)
  @read_closed = true
  @write_closed = false
  @writer = writer
end

Instance Method Details

#closeObject



23
24
25
26
27
# File 'lib/thin/response.rb', line 23

def close
  @read_closed = @write_closed = true

  nil
end

#close_readObject



33
34
35
36
37
# File 'lib/thin/response.rb', line 33

def close_read
  @read_closed = true

  nil
end

#close_writeObject



39
40
41
42
43
# File 'lib/thin/response.rb', line 39

def close_write
  @write_closed = true

  nil
end

#closed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/thin/response.rb', line 29

def closed?
  @read_closed && @write_closed
end

#flushObject



45
46
47
# File 'lib/thin/response.rb', line 45

def flush
  self
end

#read(length = nil, outbuf = nil) ⇒ Object

Raises:

  • (::IOError)


11
12
13
# File 'lib/thin/response.rb', line 11

def read(length = nil, outbuf = nil)
  raise ::IOError, 'not opened for reading' if @read_closed
end

#write(chunk) ⇒ Object Also known as: <<

Raises:

  • (::IOError)


15
16
17
18
19
# File 'lib/thin/response.rb', line 15

def write(chunk)
  raise ::IOError, 'not opened for writing' if @write_closed

  @writer.call(chunk)
end