Skip to content

appending header in HttpHeaders from '@angular/common/http' doesn't work #19044

@riyasat

Description

@riyasat

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When we use:


let header = new HttpHeaders();
header.append('abc','22');
console.log(header.get('abc'));

In console we get null

Expected behavior

We should see 22 in console

Minimal reproduction of the problem with instructions

Plunker gives error when I import HttpClientModule. But here are the steps using angular cli

  1. ng new httptest -si
  2. cd httptest
  3. edit package.json
  4. replace all old angular version to current angular version which is 4.4.0-RC.0
  5. ssave
  6. npm install
  7. edit app.module.ts

   - import { HttpClientModule } from '@angular/common/http';
   - imports:[HttpClientModule] //Added into existing import
  1. edit app.component.ts

import { HttpClient, HttpHeaders } from '@angular/common/http';
export class AppComponent {
  title = 'app';
  constructor(private http:HttpClient) {
    this.displayHeaders();
  }
  displayHeaders(){
    let header = new HttpHeaders();
    header.append('abc','22');
    

    console.log(header.get('abc'));
  }

}

9. ng serve -o
10. Check the console for output

What is the motivation / use case for changing the behavior?

no change in expected behavior. We need exact same behavior as 4.3.4

Environment


Angular version: 4.4.0-RC.0

yes it is.
Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.0.0
- Platform:  Windows

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions