WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/15/2019 07:55:13 PM (2 months ago)
Author:
kadamwhite
Message:

REST API: Do not send response body if status is 204 or body is null.

Status code 204 should indicate no response body is sent. Previously, a "null" string was sent, which MacOS Safari would try to parse as JSON and thereby fail to complete the request.

Props TimothyBlynJacobs, andizer, matthias.thiel.
Fixes #43691.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r45687 r45809  
    405405             */
    406406            $result = apply_filters( 'rest_pre_echo_response', $result, $this, $request );
     407
     408            // The 204 response shouldn't have a body.
     409            if ( 204 === $code || null === $result ) {
     410                return null;
     411            }
    407412
    408413            $result = wp_json_encode( $result );
Note: See TracChangeset for help on using the changeset viewer.