Skip to content

PATCH requests being issued as patch (lowercase), invalid against HTTP/1.1 #809

@robacarp

Description

@robacarp

I'm not entirely sure where the blame lies, but there is something weird going on with my swagger-ui installation. Our internal usage of swagger-ui shows that Rack is receiving http requests such as this:

patch /api/v1/spaces/2 HTTP/1.1
Host: localhost:3000
Connection: keep-alive
Content-Length: 13
Accept: application/json
Origin: http://localhost:3000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Content-Type: application/x-www-form-urlencoded
DNT: 1
Referer: http://localhost:3000/docs
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

deleted=false

Our server complains on receipt of that http request: Invalid request: Invalid HTTP format, parsing fails.

POST and GET requests go through just fine, and are rendered with uppercase method names:
GET /api/v1/spaces/1 HTTP/1.1 POST /api/v1/spaces HTTP/1.1

Upon extracting the request and modifying the request packet to read PATCH instead of patch, and replaying the request, it succeeds decoding and the server accepts it.

During my digging, I came across the http spec at ITEF, which lists only uppercase method names (however maybe the spec is out of date, since this copy doesn't list PATCH at all).

I started digging through the source, and I'm admittedly not a coffeejs dev, so I didn't get too far, but I have a hunch that patch wasn't considered quite as much as the other methods might have been. I suspect that many http servers are a little less pedantic about the letter case of the request method, so this might go un noticed for a while.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions