| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8fd0476 commit c997427
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,3 +345,21 @@ export function test_responseType(done) { | |||
| 345 | 345 | ); | |
| 346 | 346 | done(null); | |
| 347 | 347 | } | |
| 348 | + | ||
| 349 | + export function test_getResponseHeader() { | ||
| 350 | + const xhr = <any>new XMLHttpRequest(); | ||
| 351 | + const response = { | ||
| 352 | + statusCode: 200, | ||
| 353 | + content: { | ||
| 354 | + toString: function() { return this.raw }, | ||
| 355 | + raw: '{"data": 42}' | ||
| 356 | + }, | ||
| 357 | + headers: { | ||
| 358 | + "content-type": "application/json" | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + } | ||
| 362 | + xhr._loadResponse(response); | ||
| 363 | + | ||
| 364 | + TKUnit.assertEqual(xhr.getResponseHeader("Content-Type"), "application/json"); | ||
| 365 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,7 +119,7 @@ export class XMLHttpRequest { | |||
| 119 | 119 | this._responseTextReader = () => r.content.toString(); | |
| 120 | 120 | this._response = JSON.parse(this.responseText); | |
| 121 | 121 | ||
| 122 | - // Add toString() method to ease debugging and | ||
| 122 | + // Add toString() method to ease debugging and | ||
| 123 | 123 | // make Angular2 response.text() method work properly. | |
| 124 | 124 | Object.defineProperty(this._response, "toString", { | |
| 125 | 125 | configurable: true, | |
@@ -194,10 +194,14 @@ export class XMLHttpRequest { | |||
| 194 | 194 | public getResponseHeader(header: string): string { | |
| 195 | 195 | if (types.isString(header) && this._readyState > 1 | |
| 196 | 196 | && this._headers | |
| 197 | - && this._headers[header] | ||
| 198 | 197 | && !this._errorFlag | |
| 199 | 198 | ) { | |
| 200 | - return this._headers[header]; | ||
| 199 | + header = header.toLowerCase(); | ||
| 200 | + for (var i in this._headers) { | ||
| 201 | + if (i.toLowerCase() === header) { | ||
| 202 | + return this._headers[i]; | ||
| 203 | + } | ||
| 204 | + } | ||
| 201 | 205 | } | |
| 202 | 206 | ||
| 203 | 207 | return null; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments