Class: Stenohttp2::Server::StreamHandler::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/stenohttp2/server/stream_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ Response

Returns a new instance of Response.



39
40
41
42
# File 'lib/stenohttp2/server/stream_handler.rb', line 39

def initialize(stream)
  @content = File.read(File.join('public', 'index.html'))
  @stream = stream
end

Instance Attribute Details

#contentObject

We need this to be writable :reek:Attribute



45
46
47
# File 'lib/stenohttp2/server/stream_handler.rb', line 45

def content
  @content
end

Instance Method Details

#buildObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/stenohttp2/server/stream_handler.rb', line 47

def build
  stream.headers(
    {
      ':status' => '200',
      'content-length' => content.bytesize.to_s,
      'content-type' => 'text/html'
    },
    end_stream: false
  )
end