Class: Aws::Crt::Http::Message
- Inherits:
-
Object
- Object
- Aws::Crt::Http::Message
- Includes:
- ManagedNative
- Defined in:
- lib/aws-crt/http/message.rb
Overview
HTTP Message (request)
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(method, path, headers = {}) ⇒ Message
constructor
A new instance of Message.
- #method ⇒ Object
- #path ⇒ Object
- #to_blob_strings ⇒ Object
Methods included from ManagedNative
included, #manage_native, #native, #native_set?, #release
Constructor Details
#initialize(method, path, headers = {}) ⇒ Message
Returns a new instance of Message.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aws-crt/http/message.rb', line 14 def initialize(method, path, headers = {}) strings = [method, path] + headers.flatten blob = StringBlob.encode(strings) blob_ptr = FFI::MemoryPointer.new(:char, blob.length) blob_ptr.write_array_of_char(blob) manage_native do Aws::Crt::Native.(blob_ptr, blob.length) end end |
Instance Method Details
#headers ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/aws-crt/http/message.rb', line 32 def headers blob_strings = to_blob_strings # blob_strings must have at least 2 element and must have # pairs of header/values if blob_strings.length < 2 || blob_strings.length.odd? raise Aws::Crt::Errors::Error, 'Invalid blob_string for HTTP Message' end blob_strings[2..blob_strings.length].each_slice(2).to_h end |
#method ⇒ Object
44 45 46 |
# File 'lib/aws-crt/http/message.rb', line 44 def method to_blob_strings[0] end |
#path ⇒ Object
48 49 50 |
# File 'lib/aws-crt/http/message.rb', line 48 def path to_blob_strings[1] end |