Opened 7 years ago

Closed 7 years ago

#13347 closed bug (fixed)

PoorMan hangs for HEAD request

Reported by: kainjow Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Applications/PoorMan Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

If you send a HEAD request to PoorMan, it hangs. For example from the Terminal:

curl --HEAD http://x.x.x.x

It does *not* hang if you send an unsupported request method, for example:

curl -X PURGE http://x.x.x.x

hrev50953 x86_gcc2

Attachments (2)

0001-Fix-PoorMan-hanging-on-HEAD-requests.patch (902 bytes ) - added by kainjow 7 years ago.
0001-Fix-client-hang-when-HEAD-request-is-sent-to-PoorMan.patch (4.0 KB ) - added by kainjow 7 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by kainjow, 7 years ago

If I send a HEAD request to http://haiku-os.org it works fine, so it's not an issue with curl.

comment:2 by kainjow, 7 years ago

It will not hang if the URL returns 404, but if it returns 200 normally then it will hang. For example this works:

curl --HEAD http://x.x.x.x/asdf

comment:3 by kainjow, 7 years ago

patch: 01

comment:4 by kainjow, 7 years ago

This is now fixed with my patch.

comment:5 by pulkomandy, 7 years ago

It seems this "pointer" can only ever be set to 0 or 1. While we are touching this code, I think it should be converted to a bool and probably renamed to say what it does (obviously it is not a file_address).

Since the code is a bit unclear, an explanation of your changes in the commit message would also be appreciated (what was the problem, and why it is now solved).

Also it seems the only use for this is counting hits from the webserver. Does that still work as expected? (counting only real "hits", not 404 or other errors, and I would think not HEAD requests).

comment:6 by kainjow, 7 years ago

Yes, the use of a pointer as a bool is a questionable, I just didn't want to mess with refactoring yet. The libhttpd code looks like it was hacked to death to make it work. An ideal refactor would be to update libhttpd to latest verison, scrap all unnecessary changes, and handle directory listings in PoorManServer.

Hits are still only incremented for normal 200 requests, whether it's from a file or a directory listing. Invalid or HEAD/POST requests do not change it.

Actually, looks like it's not all the way fixed yet. Still hangs for a 200 directory listing request. I'll fix it and provide a more in-depth commit message.

comment:7 by kainjow, 7 years ago

This patch should fix it now. I also did the refactor of the variable. Looks like libhttpd actually has a bug in it with handling HEAD directory listing requests. The latest code at http://acme.com/software/thttpd/ seems to still have this.

comment:8 by pulkomandy, 7 years ago

Resolution: fixed
Status: newclosed

Applied in hrev51012. Thanks!

Note: See TracTickets for help on using tickets.