Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#363191 - 01/01/2015 12:34 Hijack reports "405 Method not allowed" when GET has content-length: 0
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
I'm using https://github.com/inaka/shotgun to talk to the Hijack HTTP server. When I do the following:

Code:
{ok, C} = shotgun:open("10.0.0.21", 80).
shotgun:get(C, "/").


...Hijack returns "405 Method Not Allowed". The request looks like this, according to wireshark:

Code:
GET / HTTP/1.1
content-length: 0
host: 10.0.0.21


Moreover, the Hijack response is contradictory, in that it looks like this:

Code:
HTTP/1.1 405 Method Not Allowed
Connection: close
Allow: GET, HEAD
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head><title>405 Method Not Allowed</title></head><body><h1>405 Method Not Allowed</h1>Server only supports GET<p></body></html>


The "Allow: GET, HEAD" contradicts the "Server only supports GET" message.
_________________________
-- roger

Top
#363197 - 01/01/2015 20:07 Re: Hijack reports "405 Method not allowed" when GET has content-length: 0 [Re: Roger]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
Weird. I wonder if it processes the GET okay, and then tries to interpret "content-length" as the next command in the pipe?

What does "content-length: 0" mean here, anyway? "Send me up to 0 bytes?"

Once I understand the request, I can fix Hijack.

Thanks.

Top
#363198 - 01/01/2015 20:12 Re: Hijack reports "405 Method not allowed" when GET has content-length: 0 [Re: Roger]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
Mmm.. reading about it now: "content-length" is meaningless when part of a GET request, and shouldn't really be sent by the client. Nothing seems to forbid it though, so I'll add support for "content-length: 0" on GET.

Cheers

Top
#363199 - 01/01/2015 20:16 Re: Hijack reports "405 Method not allowed" when GET has content-length: 0 [Re: Roger]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
Does this work for you? (Hijack zImage attached)


Attachments
zImage.bin (226 downloads)
Description: Hijack zImage file which allows/ignores "Content-length: 0" in GET,HEAD requests.



Top
#363202 - 02/01/2015 08:23 Re: Hijack reports "405 Method not allowed" when GET has content-length: 0 [Re: mlord]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Originally Posted By: mlord
Nothing seems to forbid it though, so I'll add support for "content-length: 0" on GET.


Per https://tools.ietf.org/html/rfc7230#section-3.3.2:

Quote:
A user agent SHOULD NOT send a Content-Length header field when the request message does not contain a payload body and the method semantics do not anticipate such a body.


I'll also raise a bug against the client library I'm using.
_________________________
-- roger

Top