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.



30
31
32
33
34
35
36
# File 'lib/protocol/http/error.rb', line 30

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.



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

def existing_value
  @existing_value
end

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



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

attr :existing_value

#keyObject (readonly)

Returns the value of attribute key.



39
40
41
# File 'lib/protocol/http/error.rb', line 39

def key
  @key
end

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



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

attr :key

#new_valueObject (readonly)

Returns the value of attribute new_value.



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

def new_value
  @new_value
end

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



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

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.



50
51
52
53
54
55
56
# File 'lib/protocol/http/error.rb', line 50

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