Method: OpenC3::HttpClientInterface#convert_packet_to_data

Defined in:
lib/openc3/interfaces/http_client_interface.rb

#convert_packet_to_data(packet) ⇒ Object

Called to convert a packet into a data buffer. Write protocols then potentially modify the data in their write_data methods. Finally write_interface is called to send the data to the target.

Parameters:

  • packet (Packet)

    Packet to extract data from

Returns:

  • data, extra



104
105
106
107
108
109
110
111
112
# File 'lib/openc3/interfaces/http_client_interface.rb', line 104

def convert_packet_to_data(packet)
  extra = packet.extra
  extra ||= {}
  data = packet.buffer(true) # Copy buffer so logged command isn't modified
  extra['HTTP_URI'] = URI("#{@url}#{packet.read('HTTP_PATH')}").to_s
  # Store the target name for use in identifying the response
  extra['HTTP_REQUEST_TARGET_NAME'] = packet.target_name
  return data, extra
end