This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -782,7 +782,7 @@ function $HttpProvider() {
782
782
function transformResponse ( response ) {
783
783
// make a copy since the response must be cacheable
784
784
var resp = extend ( { } , response ) ;
785
- if ( ! response . data ) {
785
+ if ( ! response . data || response . data === ' ' ) {
786
786
resp . data = response . data ;
787
787
} else {
788
788
resp . data = transformData ( response . data , response . headers , config . transformResponse ) ;
Original file line number Diff line number Diff line change @@ -1133,6 +1133,17 @@ describe('$http', function() {
1133
1133
expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( '' ) ;
1134
1134
} ) ;
1135
1135
1136
+ it ( 'should not attempt to deserialize json for a blank response whose header contains application/json' , function ( ) {
1137
+ //per http spec for Content-Type, HEAD request should return a Content-Type header
1138
+ //set to what the content type would have been if a get was sent
1139
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( ' ' , { 'Content-Type' : 'application/json' } ) ;
1140
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1141
+ $httpBackend . flush ( ) ;
1142
+
1143
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1144
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( ' ' ) ;
1145
+ } ) ;
1146
+
1136
1147
it ( 'should not deserialize tpl beginning with ng expression' , function ( ) {
1137
1148
$httpBackend . expect ( 'GET' , '/url' ) . respond ( '{{some}}' ) ;
1138
1149
$http . get ( '/url' ) . success ( callback ) ;
You can’t perform that action at this time.
0 commit comments