Skip to content

Correct response code #3

@maxm86545

Description

@maxm86545

PHP-FPM 8.0.9

Invalid request:

POST http://localhost:8081
Content-Type: application/json

{"test":"1}

json_post.flags=1 (JSON_OBJECT_AS_ARRAY):

-- Value
Response code 200 OK
empty($_POST) true
json_last_error() 0

json_post.flags=4194305 (JSON_OBJECT_AS_ARRAY + JSON_THROW_ON_ERROR):

-- Value
Response code 502 Bad Gateway
NOTICE: PHP message: PHP Fatal error:  Uncaught JsonException: Control character error, possibly incorrectly encoded in [no active file]:0
2021-09-16T07:59:36.031889207Z Stack trace:
2021-09-16T07:59:36.032174020Z #0 {main}
2021-09-16T07:59:36.032272636Z   thrown in [no active file] on line 0

Correct response code must be 400 Bad Request https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions