Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker.zig -> requestError -> missing error.BodyTooBig #107

Closed
relector-tuxnix opened this issue Mar 3, 2025 · 1 comment
Closed

worker.zig -> requestError -> missing error.BodyTooBig #107

relector-tuxnix opened this issue Mar 3, 2025 · 1 comment

Comments

@relector-tuxnix
Copy link

Just noticed 'error.BodyTooBig' is not handled by requestError, which should something like this:

fn requestError(conn: *HTTPConn, err: anyerror) !void {
    const handle = conn.stream.handle;
    switch (err) {
        error.HeaderTooBig => {
            metrics.invalidRequest();
            return writeError(handle, 431, "Request header is too big");
        },
        error.BodyTooBig => {
            metrics.invalidRequest();
            return writeError(handle, 413, "Request body is too big");
        },
        error.UnknownMethod, error.InvalidRequestTarget, error.UnknownProtocol, error.UnsupportedProtocol, error.InvalidHeaderLine, error.InvalidContentLength => {
            metrics.invalidRequest();
            return writeError(handle, 400, "Invalid Request");
        },
        error.BrokenPipe, error.ConnectionClosed, error.ConnectionResetByPeer => return,
        else => {
            log.err("server error: {}", .{err});
            metrics.internalError();
            return writeError(handle, 500, "Internal Server Error");
        },
    }
    return err;
}
karlseguin added a commit that referenced this issue Mar 3, 2025
@karlseguin
Copy link
Owner

You're right, that's better. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants