I have a Django backend. And trying to get http headers from it, using: 1) Angular 4.3 Http (it will become obsolete) 2) Normal XmlHttprequest. 3) Angular 4.3 HttpClient
1) and 2) have headers. But 3) does not.
Headings from 1):
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this); console.log(xhttp.getAllResponseHeaders()); } }; xhttp.open("GET", "http://127.0.0.1:8000/csbg/survey/sometest/", true); xhttp.send();
Headers from 2):
import { HttpModule} from '@angular/http'; this.http.get('http://127.0.0.1:8000/csbg/survey/sometest/') .subscribe( data=>{ console.log('GET OK') console.log(data) }, error=>{ console.log("GET ERROR: " + error); } )
Headings from (2)
Headings from 3):
import { HttpClient} from '@angular/common/http' this.http.get('http://127.0.0.1:8000/csbg/survey/sometest/', { observe: 'response' }) .subscribe( data=>{ console.log('GET OK') console.log(data) }, error=>{ console.log("GET ERROR: " + error); } )
No headers! Why?
Also, why are there no default Access-Control-Expose-Headers headers:
By default, only 6 simple response headers are displayed:
Cache-Control Content-Language Content Type Expires Last Modified Pragma
but my custom header?
source share