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

$http ignores HTTP headers with falsy values #2984

Closed
@romario333

Description

@romario333

$http does not send HTTP headers if they have falsy values. For example following code does not work, header is not sent.

$http(..., headers: {'Content-Version', 0})

This issue occurs at minimum in the unstable version of Angular and master.

Here is a failing test-case for $httpBackend which demonstrates the issue:

  it('should set requested headers even if they have falsy values', function() {
    $backend('POST', 'URL', null, noop, {'X-header1': 0, 'X-header2': '', 'X-header3': false});
    xhr = MockXhr.$$lastInstance;

    expect(xhr.$$reqHeaders).toEqual({
      'X-header1': 0,
      'X-header2': '',
      'X-header3': false
    });
  });

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions