Class: DigitalFabric::RequestAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/tipi/digital_fabric/request_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(agent, msg) ⇒ RequestAdapter

Returns a new instance of RequestAdapter.



7
8
9
10
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 7

def initialize(agent, msg)
  @agent = agent
  @id = msg[Protocol::Attribute::ID]
end

Instance Method Details

#finish(request) ⇒ Object



38
39
40
41
42
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 38

def finish(request)
  @agent.send_df_message(
    Protocol.http_response(@id, nil, nil, true)
  )
end

#get_body_chunk(request) ⇒ Object



16
17
18
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 16

def get_body_chunk(request)
  @agent.get_http_request_body(@id, 1)
end

#protocolObject



12
13
14
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 12

def protocol
  'df'
end

#respond(request, body, headers) ⇒ Object



20
21
22
23
24
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 20

def respond(request, body, headers)
  @agent.send_df_message(
    Protocol.http_response(@id, body, headers, true)
  )
end

#send_chunk(request, body, done:) ⇒ Object



32
33
34
35
36
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 32

def send_chunk(request, body, done: )
  @agent.send_df_message(
    Protocol.http_response(@id, body, nil, done)
  )
end

#send_headers(request, headers, opts = {}) ⇒ Object



26
27
28
29
30
# File 'lib/tipi/digital_fabric/request_adapter.rb', line 26

def send_headers(request, headers, opts = {})
    @agent.send_df_message(
      Protocol.http_response(@id, nil, headers, false)
    )
end