Skip to content

Commit bd99662

Browse files
committed
19/11/2014 V1.5.0When batching requests that have request bodies, such as POST requests, the standard angular request transforms convert objects into json strings.When angular-http-batcher calls angular.toJson again, we end up with a single json string, instead of a json encoding of the object inthe batched request.So remove this un-necessary call so a json encoding of the object is sent rather than a escaped json string to improve webAPI parameter binding.
1 parent d33a099 commit bd99662

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-http-batcher",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Enables transparent HTTP batch requests with Angular",
55
"main": "dist/angular-http-batch.min.js",
66
"keywords": [

dist/ChangeLog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
19/11/2014 V1.5.0
2+
When batching requests that have request bodies, such as "POST" requests, the standard angular request transforms convert objects into json strings.
3+
When angular-http-batcher calls angular.toJson again, we end up with a single json string, instead of a json encoding of the object in the batched request.
4+
So remove this un-necessary call so a json encoding of the object is sent rather than a escaped json string to improve webAPI parameter binding.
5+
6+
So, instead of {"name":"John"} as the body of the request in the batch, you get "{\"name\":\"John\"}" - which causes the parameter binding in Web API to break.
7+
18
19/11/2014 V1.4.0
29
The batch response parser can now handle multi-line json.
310

dist/angular-http-batch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* angular-http-batcher - v1.4.0 - 2014-11-19
2+
* angular-http-batcher - v1.5.0 - 2014-11-19
33
* https://github.com/jonsamwell/angular-http-batcher
44
* Copyright (c) 2014 Jon Samwell
55
*/
@@ -337,7 +337,8 @@ angular.module(window.ahb.name).factory('httpBatcher', [
337337
batchBody.push(constants.emptyString);
338338

339339
if (request.data) {
340-
batchBody.push(angular.toJson(request.data));
340+
//batchBody.push(angular.toJson(request.data));
341+
batchBody.push(request.data);
341342
}
342343

343344
batchBody.push(constants.emptyString);

dist/angular-http-batch.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-http-batcher",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Enables transparent HTTP batch requests with Angular",
55
"main": "angular-http-batcher.min.js",
66
"scripts": {

src/services/httpBatcher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ angular.module(window.ahb.name).factory('httpBatcher', [
185185
batchBody.push(constants.emptyString);
186186

187187
if (request.data) {
188-
batchBody.push(angular.toJson(request.data));
188+
//batchBody.push(angular.toJson(request.data));
189+
batchBody.push(request.data);
189190
}
190191

191192
batchBody.push(constants.emptyString);

tests/services/httpBatcher.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
minimumBatchSize: 1
133133
},
134134
postData = '--some_boundary_mocked\r\nContent-Type: application/http; msgtype=request\r\n\r\nPOST /resource HTTP/1.1\r\n' +
135-
'Host: www.gogle.com\r\n\r\n"{\\"propOne\\":1,\\"propTwo\\":\\"two\\",\\"propThree\\":3,\\"propFour\\":true}"\r\n\r\n--some_boundary_mocked--',
135+
'Host: www.gogle.com\r\n\r\n{"propOne":1,"propTwo":"two","propThree":3,"propFour":true}\r\n\r\n--some_boundary_mocked--',
136136
responseData = '';
137137

138138
$httpBackend.expectPOST(batchConfig.batchEndpointUrl, postData).respond(404, responseData);
@@ -189,7 +189,7 @@
189189
minimumBatchSize: 1
190190
},
191191
postData = '--some_boundary_mocked' +
192-
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nPOST /resource-two HTTP/1.1\r\nHost: www.gogle.com\r\nAuthentication: 123987\r\n\r\n"{\\"propOne\\":1,\\"propTwo\\":\\"two\\",\\"propThree\\":3,\\"propFour\\":true}"' +
192+
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nPOST /resource-two HTTP/1.1\r\nHost: www.gogle.com\r\nAuthentication: 123987\r\n\r\n{"propOne":1,"propTwo":"two","propThree":3,"propFour":true}' +
193193
'\r\n\r\n--some_boundary_mocked' +
194194
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nGET /resource HTTP/1.1\r\nHost: www.gogle.com\r\nx-custom: data123\r\nAuthentication: 1234567890' +
195195
'\r\n\r\n\r\n--some_boundary_mocked--',
@@ -454,7 +454,7 @@
454454
minimumBatchSize: 1
455455
},
456456
postData = '--some_boundary_mocked' +
457-
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nPOST /resource-two HTTP/1.1\r\nHost: www.gogle.com\r\nAuthentication: 123987\r\n\r\n"{\\"propOne\\":1,\\"propTwo\\":\\"two\\",\\"propThree\\":3,\\"propFour\\":true}"' +
457+
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nPOST /resource-two HTTP/1.1\r\nHost: www.gogle.com\r\nAuthentication: 123987\r\n\r\n{"propOne":1,"propTwo":"two","propThree":3,"propFour":true}' +
458458
'\r\n\r\n--some_boundary_mocked' +
459459
'\r\nContent-Type: application/http; msgtype=request\r\n\r\nGET /resource HTTP/1.1\r\nHost: www.gogle.com\r\nx-custom: data123\r\nAuthentication: 1234567890' +
460460
'\r\n\r\n\r\n--some_boundary_mocked--',

0 commit comments

Comments
 (0)