Exception: Protocol::HTTP::DuplicateHeaderError
- Includes:
- BadRequest
- Defined in:
- lib/protocol/http/error.rb
Overview
Raised when a singleton (e.g. content-length) header is duplicated in a request or response.
Instance Attribute Summary collapse
-
#existing_value ⇒ Object
readonly
Returns the value of attribute existing_value.
- #existing_value The existing value for the duplicated header.(Theexistingvalue) ⇒ Object readonly
-
#key ⇒ Object
readonly
Returns the value of attribute key.
- #key The header key that was duplicated.(Theheaderkeythatwasduplicated.) ⇒ Object readonly
-
#new_value ⇒ Object
readonly
Returns the value of attribute new_value.
- #new_value The new value for the duplicated header.(Thenewvalue) ⇒ Object readonly
Instance Method Summary collapse
-
#detailed_message(highlight: false) ⇒ String
Provides a detailed error message including the existing and new values.
-
#initialize(key, existing_value, new_value) ⇒ DuplicateHeaderError
constructor
A new instance of DuplicateHeaderError.
Constructor Details
#initialize(key, existing_value, new_value) ⇒ DuplicateHeaderError
Returns a new instance of DuplicateHeaderError.
22 23 24 25 26 27 28 |
# File 'lib/protocol/http/error.rb', line 22 def initialize(key, existing_value, new_value) super("Duplicate singleton header key: #{key.inspect}") @key = key @existing_value = existing_value @new_value = new_value end |
Instance Attribute Details
#existing_value ⇒ Object (readonly)
Returns the value of attribute existing_value.
34 35 36 |
# File 'lib/protocol/http/error.rb', line 34 def existing_value @existing_value end |
#existing_value The existing value for the duplicated header.(Theexistingvalue) ⇒ Object (readonly)
34 |
# File 'lib/protocol/http/error.rb', line 34 attr :existing_value |
#key ⇒ Object (readonly)
Returns the value of attribute key.
31 32 33 |
# File 'lib/protocol/http/error.rb', line 31 def key @key end |
#key The header key that was duplicated.(Theheaderkeythatwasduplicated.) ⇒ Object (readonly)
31 |
# File 'lib/protocol/http/error.rb', line 31 attr :key |
#new_value ⇒ Object (readonly)
Returns the value of attribute new_value.
37 38 39 |
# File 'lib/protocol/http/error.rb', line 37 def new_value @new_value end |
#new_value The new value for the duplicated header.(Thenewvalue) ⇒ Object (readonly)
37 |
# File 'lib/protocol/http/error.rb', line 37 attr :new_value |
Instance Method Details
#detailed_message(highlight: false) ⇒ String
Provides a detailed error message including the existing and new values.
42 43 44 45 46 47 48 |
# File 'lib/protocol/http/error.rb', line 42 def (highlight: false) " \#{self.message}\n Existing value: \#{@existing_value.inspect}\n New value: \#{@new_value.inspect}\n MESSAGE\nend\n" |