zinc
zinc copied to clipboard
Calling ZnHeaders>>#contentType raises an DNU exception if multiple Content-Type headers are present
In ZnHeaders>>#contentType
#trimBoth
is sent to header's Content-Type
value:
headerValue := (self headers at: 'Content-Type') trimBoth.
If only a single Content-Type
header was part of the response the result of (self headers at: 'Content-Type')
is a String
and everything works. However if the response specified multiple Content-Type
headers the result is an Array
and calling #trimBoth
raises an exception.
A simple testcase to raise the error:
ZnHeadersTest>>#testMultiValuedContentType
| headers |
headers := ZnHeaders new.
headers at: 'Content-Type' put: 'application/javascript'.
headers at: 'Content-Type' add: 'application/x-javascript'.
self
assert: (headers at: 'Content-Type')
equals: #('application/javascript' 'application/x-javascript').
self
shouldnt: [ headers contentType ]
raise: Error
description: '''Content-Type'' could have multiple values.'