• Hi.

    I’m experiencing an issue where our API returns 204 like this:

    $response = new WP_REST_Response();
    $response->set_status(204);
    return $response;

    The content returned is actually “null” (when changing to 200 instead) as a string, which in fact is 4 characters. I’ve tracked this down to be in the class-wp-rest-server.php file in the last 20 lines or so. More specifically, it’s the function call in the same file response_to_data which again calls $response->get_data();. This is what’s returning null. It seems like the $result variable is containing null and it’s being echoed, and therefore the server returns Content-Length: 4. This breaks the HTTP standard, as NoContent 204 should not return a body.

    Am I doing something wrong to make this $result variable null?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Content-Length: 4 when retuning 204 from server’ is closed to new replies.