This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ function defaultHttpResponseTransform(data, headers) {
26
26
* @returns {Object } Parsed headers as key value object
27
27
*/
28
28
function parseHeaders ( headers ) {
29
- var parsed = { } , key , val , i ;
29
+ var parsed = createMap ( ) , key , val , i ;
30
30
31
31
if ( ! headers ) return parsed ;
32
32
@@ -63,7 +63,11 @@ function headersGetter(headers) {
63
63
if ( ! headersObj ) headersObj = parseHeaders ( headers ) ;
64
64
65
65
if ( name ) {
66
- return headersObj [ lowercase ( name ) ] || null ;
66
+ var value = headersObj [ lowercase ( name ) ] ;
67
+ if ( value === void 0 ) {
68
+ value = null ;
69
+ }
70
+ return value ;
67
71
}
68
72
69
73
return headersObj ;
Original file line number Diff line number Diff line change @@ -816,6 +816,17 @@ describe('$http', function() {
816
816
} ) ;
817
817
818
818
819
+ it ( 'should handle empty response header' , function ( ) {
820
+ $httpBackend . expect ( 'GET' , '/url' , undefined )
821
+ . respond ( 200 , '' , { 'Custom-Empty-Response-Header' : '' , 'Constructor' : '' } ) ;
822
+ $http . get ( '/url' ) . success ( callback ) ;
823
+ $httpBackend . flush ( ) ;
824
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
825
+ expect ( callback . mostRecentCall . args [ 2 ] ( 'custom-empty-response-Header' ) ) . toBe ( '' ) ;
826
+ expect ( callback . mostRecentCall . args [ 2 ] ( 'ToString' ) ) . toBe ( null ) ;
827
+ expect ( callback . mostRecentCall . args [ 2 ] ( 'Constructor' ) ) . toBe ( '' ) ;
828
+ } ) ;
829
+
819
830
it ( 'should have delete()' , function ( ) {
820
831
$httpBackend . expect ( 'DELETE' , '/url' ) . respond ( '' ) ;
821
832
$http [ 'delete' ] ( '/url' ) ;
You can’t perform that action at this time.
0 commit comments