diff --git a/lib/client.js b/lib/client.js index 4e03bad50..6283c0aad 100644 --- a/lib/client.js +++ b/lib/client.js @@ -270,6 +270,10 @@ function Response(xhr, options) { this.text = xhr.responseText; this.setStatusProperties(xhr.status); this.header = parseHeader(xhr.getAllResponseHeaders()); + // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but + // getResponseHeader still works. so we get content-type even if getting + // other headers fails. + this.header['content-type'] = xhr.getResponseHeader('content-type'); this.setHeaderProperties(this.header); this.body = this.parseBody(this.text); }