Content-Length: 4 when retuning 204 from server
-
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.phpfile in the last 20 lines or so. More specifically, it’s the function call in the same fileresponse_to_datawhich again calls$response->get_data();. This is what’s returningnull. It seems like the $result variable is containingnulland 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?
The topic ‘Content-Length: 4 when retuning 204 from server’ is closed to new replies.