Comments (2)
I think this is introduced by: ac00e89
We could revert it (but need to make sure the original problem is still fixed), or fix this is by
enforcing the RESPONSE_BODY
always be UTF-8 encoded, as something like this:
(not tested)
class EnforceEncoding
def initialize; app; @app = app; end
def call env, &k
@app.call(env) do |res|
res[RC::RESPONSE_BODY].force_encoding('UTF-8')
k.call(res)
end
end
end
and use it before JsonResponse:
MatchingApiClient = RC::Builder.client do
use RC::DefaultSite , ENVIRONMENTS[:producton]
use RC::DefaultQuery, { threshold: 0 }
use RC::JsonRequest, true
use RC::JsonResponse, true
use EnforceEncoding
use RC::CommonLogger, method(:puts)
use RC::Cache , nil, 3600
end
However, this means we're ignoring any encoding other than UTF-8,
I am not sure if this is ok for you? Dealing with any possible encoding
is hard :( For example, if the encoding is not ASCII-7bit compatible,
then parsing JSON might fail anyway, and so on so forth.
I am thinking that, maybe we shouldn't make sure everything is
UTF-8 encoded, but make sure everything is ASCII-8bit encoded.
This is also ignoring encoding, but at least we're not giving
possibly improperly encoded UTF-8 strings.
Thoughts?
from rest-core.
This is reverted in 6c16cb8. Please let me know if this is happening again. Thanks!
from rest-core.
Related Issues (18)
- Connection refused does not emit exception, future just returns nil instead HOT 4
- FTP client support HOT 3
- JsonResponse error on redirect HOT 2
- Future and nil values HOT 5
- Stuck processes HOT 5
- Setting SSL options HOT 5
- RestCore::JsonResponse::ParseError on non-success http status code HOT 5
- Listen for "child_added" HOT 4
- support for oj gem HOT 2
- access response content as Tempfile IO object HOT 6
- add dalli extension for hash compatibility HOT 1
- rest-core [3.0.0] and Ruby 2.4.0. Not able to build client HOT 5
- RestBuilder::Promise: ERROR: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) HOT 11
- A payload within a DELETE request is ignored resulting "Invalid request data" from web services. HOT 4
- EventSource vs WebSocket? HOT 5
- "\xAD" from ASCII-8BIT to UTF-8 ERROR when requested GET HOT 7
- Unwanted payload for DELETE request from JsonRequest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-core.