uWebSockets icon indicating copy to clipboard operation
uWebSockets copied to clipboard

Add callback handler to report internal HTTP parsing errors (431, 400, 505)

Open pdeltour-syna opened this issue 3 months ago • 5 comments

In order to track all requests in my project, I also want to track incoming requests that produce an internal http parsing error (mainly 431 Request Header Fields Too Large). As internal parsing errors result in response being written to the socket and closing the socket, there is no notion of these requests in the application.

By adding a callback handler, the application can be informed of requests that produced an internal error, allowing for an application to keep track of these requests and keep metrics on that.

pdeltour-syna avatar Oct 02 '25 09:10 pdeltour-syna

Overall I like it, this was how I wanted it eventually.

You have moved this section for no reason:

            /* Parse query */
            const char *querySeparatorPtr = (const char *) memchr(req->headers->value.data(), '?', req->headers->value.length());
            req->querySeparator = (unsigned int) ((querySeparatorPtr ? querySeparatorPtr : req->headers->value.data() + req->headers->value.length()) - req->headers->value.data());

and I don't like the onHttpParserError naming as it implies generic "errors" in parsing (those are not exposed to the app and not expected to be handled by the user).

Something more specific is needed in naming. I will have a thinker

uNetworkingAB avatar Oct 02 '25 10:10 uNetworkingAB

Hi, didn't receive any feedback lately, how can we proceed with this ?

pdeltour-syna avatar Oct 20 '25 09:10 pdeltour-syna

Hi, I would like to stick with the official uWebSockets build, therefor I would like to have the callback handler included. Can you take a look ?

pdeltour-syna avatar Oct 29 '25 08:10 pdeltour-syna

Any feedback on the progress would be appreciated

pdeltour-syna avatar Nov 05 '25 09:11 pdeltour-syna

I work in bursts at times of interest, not 9-5 every day. This log callback needs thinking and tests (emitting new events is risky for things like closing the socket inside the event, unsubscribing inside the event, etc.). Also it needs thinking regarding other events for logging. It also misses some basic optimization ideas like why perform if statement when you can just set the handler by default, etc. I don't like the switch I don't like the interface, it's low prio, etc.

uNetworkingAB avatar Nov 05 '25 13:11 uNetworkingAB