Exception: Protocol::HTTP::DuplicateHeaderError

Inherits:
Error
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(key, existing_value, new_value) ⇒ DuplicateHeaderError

Returns a new instance of DuplicateHeaderError.



35
36
37
38
39
40
41
# File 'lib/protocol/http/error.rb', line 35

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_valueObject (readonly)

Returns the value of attribute existing_value.



47
48
49
# File 'lib/protocol/http/error.rb', line 47

def existing_value
  @existing_value
end

#existing_value The existing value for the duplicated header.(Theexistingvalue) ⇒ Object (readonly)



47
# File 'lib/protocol/http/error.rb', line 47

attr :existing_value

#keyObject (readonly)

Returns the value of attribute key.



44
45
46
# File 'lib/protocol/http/error.rb', line 44

def key
  @key
end

#key The header key that was duplicated.(Theheaderkeythatwasduplicated.) ⇒ Object (readonly)



44
# File 'lib/protocol/http/error.rb', line 44

attr :key

#new_valueObject (readonly)

Returns the value of attribute new_value.



50
51
52
# File 'lib/protocol/http/error.rb', line 50

def new_value
  @new_value
end

#new_value The new value for the duplicated header.(Thenewvalue) ⇒ Object (readonly)



50
# File 'lib/protocol/http/error.rb', line 50

attr :new_value

Instance Method Details

#detailed_message(highlight: false) ⇒ String

Provides a detailed error message including the existing and new values.

Returns:

  • (String)

    The detailed error message.



55
56
57
58
59
60
61
# File 'lib/protocol/http/error.rb', line 55

def detailed_message(highlight: false)
	<<~MESSAGE
		#{self.message}
			Existing value: #{@existing_value.inspect}
			New value: #{@new_value.inspect}
	MESSAGE
end