From 0f27b50091a20bbf6b6fb2944d1831f715a214f2 Mon Sep 17 00:00:00 2001 From: e2tox Date: Wed, 20 Jun 2012 11:38:28 +0800 Subject: [PATCH 1/2] batch command does not support non-ascii entity --- lib/services/table/batchserviceclient.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/services/table/batchserviceclient.js b/lib/services/table/batchserviceclient.js index 9ece405942..6b7ad75bc7 100644 --- a/lib/services/table/batchserviceclient.js +++ b/lib/services/table/batchserviceclient.js @@ -1,4 +1,4 @@ -/** +/** * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -100,10 +100,9 @@ BatchServiceClient.prototype.addOperation = function (webResource, outputData) { webResource.headers[HeaderConstants.CONTENT_ID] = this.operations.length + 1; if (webResource.httpVerb !== ServiceClient.HTTP_VERB_DELETE) { - webResource.headers[HeaderConstants.CONTENT_TYPE] = 'application/atom+xml;type=entry'; + webResource.headers[HeaderConstants.CONTENT_TYPE] = 'application/atom+xml;charset="utf-8";type=entry'; } - - webResource.headers[HeaderConstants.CONTENT_LENGTH] = outputData.length; + webResource.headers[HeaderConstants.CONTENT_LENGTH] = Buffer.byteLength(outputData, 'utf8'); //outputData.length; } this._setRequestUrl(webResource); @@ -149,7 +148,7 @@ BatchServiceClient.prototype.commitBatch = function (optionsOrCallback, callback var changesetBoundary = 'changeset_' + crypto.createHash('md5').update("" + (new Date()).getTime()).digest("hex"); var body = '--' + batchBoundary + '\n'; - body += HeaderConstants.CONTENT_TYPE + ': multipart/mixed; boundary=' + changesetBoundary + '\n\n'; + body += HeaderConstants.CONTENT_TYPE + ': multipart/mixed;charset="utf-8";boundary=' + changesetBoundary + '\n\n'; for (var operation in this.operations) { body += '--' + changesetBoundary + '\n'; @@ -165,10 +164,10 @@ BatchServiceClient.prototype.commitBatch = function (optionsOrCallback, callback .withOkCode(HttpConstants.HttpResponseCodes.ACCEPTED_CODE) .withRawResponse(true); - webResource.addOptionalHeader(HeaderConstants.CONTENT_TYPE, 'multipart/mixed; boundary=' + batchBoundary); + webResource.addOptionalHeader(HeaderConstants.CONTENT_TYPE, 'multipart/mixed;charset="utf-8";boundary=' + batchBoundary); webResource.addOptionalHeader(HeaderConstants.DATA_SERVICE_VERSION, '1.0;NetFx'); webResource.addOptionalHeader(HeaderConstants.MAX_DATA_SERVICE_VERSION, '2.0;NetFx'); - webResource.addOptionalHeader(HeaderConstants.CONTENT_LENGTH, body.length); + webResource.addOptionalHeader(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(body, 'utf8')); var self = this; From 59c6e98f7cbb49ec734ef6b9c950a6b0aae6a423 Mon Sep 17 00:00:00 2001 From: e2tox Date: Wed, 20 Jun 2012 15:36:10 +0800 Subject: [PATCH 2/2] Update master --- lib/services/table/batchserviceclient.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/services/table/batchserviceclient.js b/lib/services/table/batchserviceclient.js index 6b7ad75bc7..f123f2249a 100644 --- a/lib/services/table/batchserviceclient.js +++ b/lib/services/table/batchserviceclient.js @@ -102,7 +102,8 @@ BatchServiceClient.prototype.addOperation = function (webResource, outputData) { if (webResource.httpVerb !== ServiceClient.HTTP_VERB_DELETE) { webResource.headers[HeaderConstants.CONTENT_TYPE] = 'application/atom+xml;charset="utf-8";type=entry'; } - webResource.headers[HeaderConstants.CONTENT_LENGTH] = Buffer.byteLength(outputData, 'utf8'); //outputData.length; + + webResource.headers[HeaderConstants.CONTENT_LENGTH] = Buffer.byteLength(outputData, 'utf8'); } this._setRequestUrl(webResource);