This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -771,7 +771,7 @@ function $HttpProvider() {
771
771
function transformResponse ( response ) {
772
772
// make a copy since the response must be cacheable
773
773
var resp = extend ( { } , response ) ;
774
- if ( config . method === 'HEAD' ) {
774
+ if ( ! response . data ) {
775
775
resp . data = response . data ;
776
776
} else {
777
777
resp . data = transformData ( response . data , response . headers , config . transformResponse ) ;
Original file line number Diff line number Diff line change @@ -1116,6 +1116,16 @@ describe('$http', function() {
1116
1116
expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( '' ) ;
1117
1117
} ) ;
1118
1118
1119
+ it ( 'should not attempt to deserialize json for an empty response whose header contains application/json' , function ( ) {
1120
+ //per http spec for Content-Type, HEAD request should return a Content-Type header
1121
+ //set to what the content type would have been if a get was sent
1122
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( '' , { 'Content-Type' : 'application/json' } ) ;
1123
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1124
+ $httpBackend . flush ( ) ;
1125
+
1126
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1127
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( '' ) ;
1128
+ } ) ;
1119
1129
1120
1130
it ( 'should not deserialize tpl beginning with ng expression' , function ( ) {
1121
1131
$httpBackend . expect ( 'GET' , '/url' ) . respond ( '{{some}}' ) ;
You can’t perform that action at this time.
0 commit comments