Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($http): add utf-8 to default Content-Type header (post/put)
Browse files Browse the repository at this point in the history
This fixes special characters issue with MongoLab.

https://groups.google.com/d/topic/angular/1T6h7bfZ7Rs/discussion
  • Loading branch information
vojtajina authored and IgorMinar committed Jun 8, 2012
1 parent c3a41ff commit 10f80d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function $HttpProvider() {
'Accept': 'application/json, text/plain, */*',
'X-Requested-With': 'XMLHttpRequest'
},
post: {'Content-Type': 'application/json'},
put: {'Content-Type': 'application/json'}
post: {'Content-Type': 'application/json;charset=utf-8'},
put: {'Content-Type': 'application/json;charset=utf-8'}
}
};

Expand Down
4 changes: 2 additions & 2 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ describe('$http', function() {
$httpBackend.expect('POST', '/url', 'messageBody', function(headers) {
return headers['Accept'] == 'application/json, text/plain, */*' &&
headers['X-Requested-With'] == 'XMLHttpRequest' &&
headers['Content-Type'] == 'application/json';
headers['Content-Type'] == 'application/json;charset=utf-8';
}).respond('');

$http({url: '/url', method: 'POST', headers: {}, data: 'messageBody'});
Expand All @@ -396,7 +396,7 @@ describe('$http', function() {
$httpBackend.expect('PUT', '/url', 'messageBody', function(headers) {
return headers['Accept'] == 'application/json, text/plain, */*' &&
headers['X-Requested-With'] == 'XMLHttpRequest' &&
headers['Content-Type'] == 'application/json';
headers['Content-Type'] == 'application/json;charset=utf-8';
}).respond('');

$http({url: '/url', method: 'PUT', headers: {}, data: 'messageBody'});
Expand Down

0 comments on commit 10f80d7

Please sign in to comment.