Skip to content

Headers with leading underscore being rewritten to dashes #337

@peterc

Description

@peterc

Similar to #317

I'm coding against a (popular) API that claims to support DELETE but which, sadly, does not. It requires you POST and set a _method header to POST instead.

Unfortunately, setting a "method" header results in HTTP::Headers.normalize_header changing the "" to a "-" as part of its normalization process and the header becomes "-Method" which doesn't work.

I believe the first line of normalize_header is in error to only return the existing header name if it is already in canonical form. I believe it should return if it is already compliant instead. Doing this resolves the issue in my case. That is, a simple change from:

return name if name =~ CANONICAL_NAME_RE

to

return name if name =~ COMPLIANT_NAME_RE

Could someone with more knowledge than me verify if my assertions above are correct? If so, I am more than happy to put in a pull request, and even more happy if someone just wants to make the change (or explain why this behavior is desirable, naturally) :-)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions