This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -782,7 +782,7 @@ function $HttpProvider() {
782782 function transformResponse ( response ) {
783783 // make a copy since the response must be cacheable
784784 var resp = extend ( { } , response ) ;
785- if ( ! response . data ) {
785+ if ( ! response . data || response . data === '' ) {
786786 resp . data = response . data ;
787787 } else {
788788 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() {
11331133 expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( '' ) ;
11341134 } ) ;
11351135
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+
11361147 it ( 'should not deserialize tpl beginning with ng expression' , function ( ) {
11371148 $httpBackend . expect ( 'GET' , '/url' ) . respond ( '{{some}}' ) ;
11381149 $http . get ( '/url' ) . success ( callback ) ;
You can’t perform that action at this time.
0 commit comments