Class: Dkim::Header
- Inherits:
-
Struct
- Object
- Struct
- Dkim::Header
- Includes:
- Canonicalizable
- Defined in:
- lib/dkim/header.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #canonical_relaxed ⇒ Object
- #canonical_simple ⇒ Object
- #relaxed_key ⇒ Object
- #relaxed_value ⇒ Object
Methods included from Canonicalizable
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key
4 5 6 |
# File 'lib/dkim/header.rb', line 4 def key @key end |
#value ⇒ Object
Returns the value of attribute value
4 5 6 |
# File 'lib/dkim/header.rb', line 4 def value @value end |
Class Method Details
.parse(header_string) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/dkim/header.rb', line 42 def self.parse header_string header_string.split(/\r?\n(?!([ \t]))/).map do |header| key, value = header.split(':', 2) new(key, value) end end |
Instance Method Details
#canonical_relaxed ⇒ Object
35 36 37 |
# File 'lib/dkim/header.rb', line 35 def canonical_relaxed "#{relaxed_key}:#{relaxed_value}" end |
#canonical_simple ⇒ Object
38 39 40 |
# File 'lib/dkim/header.rb', line 38 def canonical_simple "#{key}:#{value}" end |
#relaxed_key ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dkim/header.rb', line 7 def relaxed_key key = self.key.dup #Convert all header field names (not the header field values) to lowercase. For example, convert "SUBJect: AbC" to "subject: AbC". key.downcase! # Delete any WSP characters remaining before the colon separating the header field name from the header field value. key.gsub!(/[ \t]*\z/, '') key end |
#relaxed_value ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dkim/header.rb', line 18 def relaxed_value value = self.value.dup # Unfold all header field continuation lines as described in [RFC2822] value.gsub!(/\r?\n[ \t]+/, ' ') # Convert all sequences of one or more WSP characters to a single SP character. value.gsub!(/[ \t]+/, ' ') # Delete all WSP characters at the end of each unfolded header field value. value.gsub!(/[ \t]*\z/, '') # Delete any WSP characters remaining after the colon separating the header field name from the header field value. value.gsub!(/\A[ \t]*/, '') value end |