daemon/http: HTTP response codes
Fixes #728 (closed)
Related #618 (closed)
Currently:
- Replies with
400
when aGET
query has no DNS query in it (the basic case in #728 (closed)) - Replies with
404
when querying unknown endpoints (anything other than/doh
or/dns-query
) - Replies with
431
when a header is too large
To do:
-
Reply with 400
when thePOST
body is malformed (but only if DNS itself cannot deal with it, then it is200
as per RFC 8484) -
Reply with(changed to413
when thePOST
body is too long (attempted but not working at the moment)400
) -
Reply with(changed to414
when theGET
URL is too long400
) -
Check RFCs for more codes -
Make sure the way it's currently simply calling http_send_response
on error does not cause any problems -
Possibly more?
Merge request reports
Activity
added 1 commit
- 5b15050e - fixup! daemon/http: add basic HTTP response codes
added 1 commit
- 22217915 - daemon/http: return 400 on stream end with no processed packets
added 1 commit
- 281f9cad - daemon/http: return 400 on failed packet_parse + improved stream handling
marked the checklist item Reply with
400
when thePOST
body is malformed (but only if DNS itself cannot deal with it, then it is200
as per RFC 8484) as completedadded 1 commit
- f1509cbb - fixup! daemon/http: return 400 on failed packet_parse + improved stream handling
added 9 commits
-
f1509cbb...d1988269 - 6 commits from branch
master
- 1c453b61 - daemon/http: add basic HTTP response codes
- 22d95750 - daemon/http: return 400 on stream end with no processed packets
- c7abc86a - daemon/http: return 400 on failed packet_parse + improved stream handling
Toggle commit list-
f1509cbb...d1988269 - 6 commits from branch
- Resolved by Vladimír Čunát
The Lua config "too long POST" test currently has issues with its connection timing out. I'm not sure what that is about, both
curl
and PowerShell'sInvoke-RestMethod
seem to react as intended to the response code (tested with similar HTTP body data as present in the test). I have commented that test out for now.I can try investigating further, but I have spent a lot of time debugging this and still haven't found what the problem is.
Edited by Oto Šťáva
I have changed the "too long POST" and "too long GET" response codes to the generic
400
. In the worker, I can easily find out that no packets were successfully parsed from the request, but not why.Also, as per RFC 2616, I think that the
413
and414
response codes are meant to indicate that the HTTP server itself is unwilling/unable to process long requests, with414
even being called rare. Since the length of a packet is not being checked by the HTTP part of the resolver, but bylibknot
, the400
response code might actually be more appropriate.For unsupported HTTP methods, I have changed the response from
405
to501
. I think it is more appropriate, as our HTTP server itself does not implement any methods other thanGET
,POST
, and newlyHEAD
(as it is required by RFC 2616) anywhere. The405
response is also required to include anAllow
header, while501
is not.Edited by Oto Šťávaadded 1 commit
- 05d1c744 - fixup! daemon/http: return 400 on failed packet_parse + improved stream handling