mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1243594 (part 3) - leave the utf-8 encoding of the payload to rest.js instead of directly in loop. r=Standard8
This commit is contained in:
parent
32d720116b
commit
7e3515b689
@ -613,7 +613,9 @@ var MozLoopServiceInternal = {
|
||||
2 * 32, true);
|
||||
}
|
||||
|
||||
if (payloadObj) {
|
||||
// Later versions of Firefox will do utf-8 encoding of the request, but
|
||||
// we need to do it ourselves for older versions.
|
||||
if (!gHawkClient.willUTF8EncodeRequests && payloadObj) {
|
||||
// Note: we must copy the object rather than mutate it, to avoid
|
||||
// mutating the values of the object passed in.
|
||||
let newPayloadObj = {};
|
||||
|
@ -12,12 +12,13 @@
|
||||
Cu.import("resource://services-common/utils.js");
|
||||
|
||||
add_task(function* request_with_unicode() {
|
||||
const unicodeName = "yøü";
|
||||
// Note unicodeName must be unicode, not utf-8
|
||||
const unicodeName = "y\xf8\xfc"; // "yøü"
|
||||
|
||||
loopServer.registerPathHandler("/fake", (request, response) => {
|
||||
let body = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
|
||||
let jsonBody = JSON.parse(body);
|
||||
Assert.equal(jsonBody.name, CommonUtils.encodeUTF8(unicodeName));
|
||||
let jsonBody = JSON.parse(CommonUtils.decodeUTF8(body));
|
||||
Assert.equal(jsonBody.name, unicodeName);
|
||||
|
||||
response.setStatusLine(null, 200, "OK");
|
||||
response.processAsync();
|
||||
|
@ -100,6 +100,11 @@ this.HawkClient = function(host) {
|
||||
|
||||
this.HawkClient.prototype = {
|
||||
|
||||
/*
|
||||
* A boolean for feature detection.
|
||||
*/
|
||||
willUTF8EncodeRequests: HAWKAuthenticatedRESTRequest.prototype.willUTF8EncodeObjectRequests,
|
||||
|
||||
/*
|
||||
* Construct an error message for a response. Private.
|
||||
*
|
||||
|
@ -104,6 +104,13 @@ RESTRequest.prototype = {
|
||||
|
||||
/*** Public API: ***/
|
||||
|
||||
/**
|
||||
* A constant boolean that indicates whether this object will automatically
|
||||
* utf-8 encode request bodies passed as an object. Used for feature detection
|
||||
* so, eg, loop can use the same source code for old and new Firefox versions.
|
||||
*/
|
||||
willUTF8EncodeObjectRequests: true,
|
||||
|
||||
/**
|
||||
* URI for the request (an nsIURI object).
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user