From 52416064cbec5026a4599b835ca8e777c37207eb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 11 Feb 2013 14:10:59 -0500 Subject: [PATCH] get content-type even if can't get other headers. fixes #181 --- lib/client.js | 4 ++++ 1 file changed, 4 insertions(+) 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); }