Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jqXHR.getResponseHeader #3403

Closed
PSPvZ opened this issue Nov 18, 2016 · 4 comments
Closed

jqXHR.getResponseHeader #3403

PSPvZ opened this issue Nov 18, 2016 · 4 comments

Comments

@PSPvZ
Copy link

@PSPvZ PSPvZ commented Nov 18, 2016

Description

jqXHR.getResponseHeader fails to combine multiple HTTP headers with the same name. Instead, it only returns the value of the last HTTP header. This clashes with the specification of XMLHttpRequest.getResponseHeader, which states: "If there are multiple response headers with the same name, then their values are returned as a single concatenated string, where each value is separated from the previous one by a pair of comma and space."

The issue seems to occur only on Internet Explorer (I encountered it on IE11); calling IE's own XMLHttpRequest.getRequestHeader implementation does return the correct result,

From what I can tell Firefox 50 already combined the two headers into one before calling the XMLHttpRequest completion callback, inadvertently allowing jQuery to return the correct result.

Tested in jQuery 3.1.1.

Link to test case

I have no test-environment that can easily set multiple headers with the same name, unfortunately.

@gibson042
Copy link
Member

@gibson042 gibson042 commented Nov 21, 2016

The problem seems to be misimplementation of getAllResponseHeaders (on which we rely) in at least IE11, but I otherwise agree with this assessment.

@PSPvZ, would you be willing to submit a PR updating our getResponseHeader to something like responseHeaders[ match[ 1 ].toLowerCase() ] = (responseHeaders[ match[ 1 ].toLowerCase() ] || []).concat( match[ 2 ] ); … return match == null ? null : match.join( ", " )?

@timmywil timmywil added this to the 4.0.0 milestone Nov 21, 2016
@pankajpatel
Copy link

@pankajpatel pankajpatel commented Nov 23, 2016

Hello,
I tried to create a test for this which can be seen here:
$getJSON: http://jsbin.com/vofipib/edit?js,console
$get: http://jsbin.com/texago/edit?js,console
XMLHttpRequest: http://jsbin.com/pugemo/edit?js,console
Can I contribute on this issue?

@gibson042
Copy link
Member

@gibson042 gibson042 commented Nov 23, 2016

Can I contribute on this issue?

Yes! https://contribute.jquery.org/commits-and-pull-requests/

@markelog markelog removed this from the 4.0.0 milestone Dec 5, 2016
@timmywil timmywil added this to the Future milestone Dec 19, 2016
@gibson042 gibson042 added the Bug label Dec 19, 2016
@timmywil timmywil added this to the 3.2.0 milestone Dec 19, 2016
@timmywil timmywil removed this from the Future milestone Dec 19, 2016
@timmywil timmywil removed this from the 3.2.0 milestone Mar 6, 2017
@timmywil timmywil added this to the 3.3.0 milestone Mar 6, 2017
@timmywil timmywil added this to the 3.3.0 milestone Mar 6, 2017
@timmywil timmywil removed this from the 3.2.0 milestone Mar 6, 2017
@timmywil timmywil added this to the Future milestone Mar 27, 2017
@timmywil timmywil removed this from the 3.3.0 milestone Mar 27, 2017
@Andrei15193
Copy link
Contributor

@Andrei15193 Andrei15193 commented Sep 13, 2018

The problem seems to be misimplementation of getAllResponseHeaders (on which we rely) in at least IE11, but I otherwise agree with this assessment.

@PSPvZ, would you be willing to submit a PR updating our getResponseHeader to something like responseHeaders[ match[ 1 ].toLowerCase() ] = (responseHeaders[ match[ 1 ].toLowerCase() ] || []).concat( match[ 2 ] ); … return match == null ? null : match.join( ", " )?

@gibson042, done: #4173

@timmywil timmywil removed this from the Future milestone Nov 26, 2018
@timmywil timmywil added this to the 3.4.0 milestone Nov 26, 2018
@timmywil timmywil closed this in e0d9411 Nov 26, 2018
mgol added a commit to mgol/jquery that referenced this issue Dec 14, 2018
Android Browser only returns the last value for each header so there's no way
for jQuery get all parts.

Ref jquerygh-3403
Ref jquerygh-4173
mgol added a commit to mgol/jquery that referenced this issue Dec 14, 2018
Android Browser only returns the last value for each header so there's no way
for jQuery get all parts.

Ref jquerygh-3403
Ref jquerygh-4173
mgol added a commit to mgol/jquery that referenced this issue Dec 14, 2018
Android Browser only returns the last value for each header so there's no way
for jQuery get all parts.

Ref jquerygh-3403
Ref jquerygh-4173
mgol added a commit that referenced this issue Dec 14, 2018
Android Browser only returns the last value for each header so there's no way
for jQuery get all parts.

Closes gh-4259
Ref gh-3403
Ref gh-4173
@lock lock bot locked as resolved and limited conversation to collaborators Jul 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
@timmywil @pankajpatel @markelog @gibson042 @mgol @Andrei15193 @PSPvZ and others