Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Send HTTP errors instead of the success flag

This will eventually spare us a layer in the protocol.

Currently whenever the client processes errors we understand both the
flag notation and the HTTP status message, so we don't need client
mods right now.
  • Loading branch information...
commit 2532397953f4c59face334bc1fb93ca55f57a2a1 1 parent b004319
@nb nb authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 liveblog.php
View
15 liveblog.php
@@ -326,6 +326,12 @@ function json_return( $success, $message, $data = array() ) {
'data' => $data,
) );
+ $success = intval( $success );
+ if ( !$success ) {
+ self::status_header_with_message( 500, $message );
+ exit;
+ }
+
header( 'Content-Type: application/json' );
if ( self::$do_not_cache_response ) {
nocache_headers();
@@ -334,6 +340,15 @@ function json_return( $success, $message, $data = array() ) {
exit;
}
+ function status_header_with_message( $status, $message ) {
+ global $wp_header_to_desc;
+ $status = absint( $status );
+ $official_message = isset( $wp_header_to_desc[$status] )? $wp_header_to_desc[$status] : '';
+ $wp_header_to_desc[$status] = $message;
+ status_header( $status );
+ $wp_header_to_desc[$status] = $official_message;
+ }
+
}
WPCOM_Liveblog::load();
Please sign in to comment.
Something went wrong with that request. Please try again.