Skip to content

I cannot catch errors raised by swoole before parsing HTTP request #5752

Open
@godfreybwaira

Description

@godfreybwaira

I want to check the maximum request size so that when a user upload a file larger that package_max_length I can reject the request. But swoole does not allow me to check for this error, instead it shows warning [2025-05-07 14:16:32 *15066.2] WARNING Port_onRead_http() (ERRNO 7102): Request Entity Too Large: header-length (290) + content-length (1575386) is greater than the package_max_length(1048576) from session#1 on 0.0.0.0:8008

How Do I handle this kind of error programmatically so that I can send 413 status code to a client?.

I suggest you create

$server->on('error', function(Request $req, Response $res){
//handle payload errors and other errors gracefully
});

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions