Class: As2::Parser::DispositionNotificationOptions Private

Inherits:
Object
  • Object
show all
Defined in:
lib/as2/parser/disposition_notification_options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

parse an AS2 HTTP Content-Disposition-Options header Structure is described in datatracker.ietf.org/doc/html/rfc4130#section-7.3

don’t use this directly. use As2.choose_mic_algorithm instead.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.normalize_key(raw) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/as2/parser/disposition_notification_options.rb', line 21

def self.normalize_key(raw)
  raw.to_s.downcase
end

.parse(raw_body) ⇒ As2::Parser::DispositionNotificationOptions::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

parse a single header body (without the name)

Examples:

parse(‘signed-receipt-protocol=required, pkcs7-signature; signed-receipt-micalg=optional, sha1’)

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/as2/parser/disposition_notification_options.rb', line 29

def self.parse(raw_body)
  value = nil
  attributes = {}

  body_parts = raw_body.to_s.split(';').map(&:strip)

  body_parts.each do |part|
    if part.include?('=')
      part_key, _, part_value = part.partition('=')
      part_value = split_part(part_value)

      # force lower-case to make access more reliable
      part_key = normalize_key(part_key)

      attributes[part_key] = part_value
    else
      value = split_part(part)
    end
  end

  Result.new(raw: raw_body, value: value, attributes: attributes)
end