nemasu / asmttpd

Web server for Linux written in amd64 assembly.
GNU General Public License v2.0
3.03k stars 199 forks source link

Bad "Content-Length" header #17

Closed egorsmkv closed 8 years ago

egorsmkv commented 9 years ago
~ > curl --head http://my_host/
HTTP/1.1 200 OK
Server: asmttpd/0.3
Accept-Ranges: bytes
Content-Length: 9223372036854775807                <- ERROR
Content-Type: application/octet-stream

index.html:

hello
nemasu commented 9 years ago

Hello, there is no HEAD support, I suppose it should respond as such, but it's currently not implemented to do so.

HEAD may appear to currently work, but it's just sending a regular response along with the content, curl just doesn't show it, but if you pass the -v option, it will mention an excess found at the end (i.e. the content).

triforce commented 8 years ago

This needs to be reopened as an invalid length is being returned from a HEAD request.

nemasu commented 8 years ago

I think it should return a 405 error, or the feature be implemented.

triforce commented 8 years ago

It should return a 200 response but without a message body, but obviously the content length needs to be calculated correctly.

After some testing this only happens when requesting a directory root (i.e no file is specified) and it should respond with the length of the default index file.

Line 237 in main.asm.

"cmp r9, 0x06 ;TODO why exactly is this 6?"

The 0x06 looks to be the offset of the root file request. However when it is a HEAD request this is obviously one offset byte longer than a GET.