Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #24 from duckduckgo/dylan/api_response-utf8-encoding

encode utf8 api_responses to bytestream for plack
  • Loading branch information...
commit 8a66e8393ea8afbac1546acf60097f874cb50280 2 parents 9a54351 + 9e41603
@moollaza moollaza authored
View
2  lib/App/DuckPAN/Web.pm
@@ -129,6 +129,8 @@ sub request {
));
if ($res->is_success) {
$body = $res->decoded_content;
+ # Encode utf8 api_responses to bytestream for Plack.
+ utf8::encode $body if utf8::is_utf8 $body;
warn "Cannot use wrap_jsonp_callback and wrap_string callback at the same time!" if $rewrite->wrap_jsonp_callback && $rewrite->wrap_string_callback;
if ($rewrite->wrap_jsonp_callback && $rewrite->callback) {
$body = $rewrite->callback.'('.$body.');';
View
3  lib/App/DuckPAN/WebPublisher.pm
@@ -89,6 +89,9 @@ sub request {
}
}
+ # This could cause issues with incorrectly encoded data as Plack expects a
+ # raw bytestream. We should find the root of this issue and reencode
+ # offending strings.
Encode::_utf8_off($body);
$response->body($body);
return $response;
View
3  lib/App/DuckPAN/WebStatic.pm
@@ -88,6 +88,9 @@ sub request {
}
}
+ # This could cause issues with incorrectly encoded data as Plack expects a
+ # raw bytestream. We should find the root of this issue and reencode
+ # offending strings.
Encode::_utf8_off($body);
$response->body($body);
return $response;
Please sign in to comment.
Something went wrong with that request. Please try again.