Skip to content

http Response headers incomplete ? #13226

@vfedoriv

Description

@vfedoriv

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

If I get Response from http request, response.headers contain only "application/json; charset=utf-8"

import { Component, OnInit } from '@angular/core';
import {Http} from "@angular/http";

@Component({
  selector: 'app-simple-test',
  templateUrl: './simple-test.component.html',
  styleUrls: ['./simple-test.component.css']
})
export class SimpleTestComponent implements OnInit {

  private test_url = "http://www.mocky.io/v2/5843ecc6100000da1c1a5734";
  private output_string ="";

  constructor(private http: Http) { }

  ngOnInit() {
    this.http.get(this.test_url)
      .subscribe(response => {
        this.output_string = "response: " + response + "; response headers values: " + response.headers.values();
      }, (error) => {
        console.log(error);
      });
  }
}

headers_test

Expected behavior
Expected: get list all headers from http response

Minimal reproduction of the problem with instructions

I create link with REST response there: http://www.mocky.io/v2/5843ecc6100000da1c1a5734
(with added headers "Access-Control-Allow-Origin: *" and "Errors: error message")
and create test
Plunker link: http://plnkr.co/edit/vJD4Zuo0MxKAdb4nA1Xl?p=preview

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

parsing response headers from backend application

Please tell us about your environment:

Win10 64bit, npm 4.0.3

  • Angular version: 2.2.X
  • Browser: [ Chrome 54 | Firefox 50 ]
  • Language: [TypeScript 2.0.10]

  • Node (for AoT issues): node --version = 7.2.0

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