[Bps-public-commit] rt-extension-rest2 branch, dev, updated. 5061966e7b20f35203e08cc5a5db6b725645b9b5

Dustin Graves dustin at bestpractical.com
Fri Jul 29 20:54:01 EDT 2016


The branch, dev has been updated
       via  5061966e7b20f35203e08cc5a5db6b725645b9b5 (commit)
       via  7247997ed9d95bbf8cc47ae632503cf1d262e8e0 (commit)
      from  4f3e410e9e3a950a98e3feb7140304da3c2da8db (commit)

Summary of changes:
 lib/RT/Extension/REST2/Util.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 7247997ed9d95bbf8cc47ae632503cf1d262e8e0
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Sat Jul 30 00:51:26 2016 +0000

    use Plack::Response->content_type instead of Plack::Response->header

diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index 214fda6..38006f9 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -155,7 +155,7 @@ sub deserialize_record {
 sub error_as_json {
     my $response = shift;
     my $return = shift;
-    $response->header( "Content-type" => "application/json; charset=utf-8" );
+    $response->content_type( "application/json; charset=utf-8" );
     $response->body( JSON::encode_json({ message => join "", @_ }) );
     return $return;
 }

commit 5061966e7b20f35203e08cc5a5db6b725645b9b5
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Sat Jul 30 00:52:56 2016 +0000

    set Content-Length header on error_as_json response
    
    previously it was using the content length of the original message which
    was truncating the new jsonified  message

diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index 38006f9..fcb98f8 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -155,8 +155,13 @@ sub deserialize_record {
 sub error_as_json {
     my $response = shift;
     my $return = shift;
+
+    my $body = JSON::encode_json({ message => join "", @_ });
+
     $response->content_type( "application/json; charset=utf-8" );
-    $response->body( JSON::encode_json({ message => join "", @_ }) );
+    $response->content_length( length $body );
+    $response->body( $body );
+
     return $return;
 }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list