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

[BUGFIX beta] Allow optional spaces when parsing response headers #4137

Merged
merged 1 commit into from
Feb 12, 2016

Conversation

HeroicEric
Copy link
Member

Fixes #4122

  • Allows header field-value without preceding whitespace
  • Removes leading/trailing whitespace from header field-names
  • Removes leading/trailing whitespace from header field-values
  • Moves parseResponseHeaders function out of DS.RestAdapter to its own module

The main reason for moving to a module was to make it easier to unit test in order to document current behavior before making the fix. Let me know if this is undesirable.

@HeroicEric HeroicEric changed the title [WIP] [BUGFIX] Allow optional spaces when parsing response headers [BUGFIX beta] Allow optional spaces when parsing response headers Feb 6, 2016
Fixes emberjs#4122

- Allows header field-value without preceding whitespace
- Removes leading/trailing whitespace from header field-names
- Removes leading/trailing whitespace from header field-values
- Moves `parseResponseHeaders` function out of `DS.RestAdapter` to its
  own module

The main reason for moving to a module was to make it easier to unit
test in order to document current behavior before making the fix. Let me
know if this is undesirable.
let headerPairs = headersString.split(CLRF);

headerPairs.forEach((header) => {
let [field, ...value] = header.split(':');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ES6 😍

@pangratz
Copy link
Member

This looks very good to me 👍 . Much more readable now! Thanks @HeroicEric!

@bmac
Copy link
Member

bmac commented Feb 12, 2016

Thanks @HeroicEric. You rock!

bmac added a commit that referenced this pull request Feb 12, 2016
[BUGFIX beta] Allow optional spaces when parsing response headers
@bmac bmac merged commit 11627a9 into emberjs:master Feb 12, 2016
@HeroicEric HeroicEric deleted the bugfix-4122 branch February 13, 2016 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parseResponseHeaders does not follow HTTP spec of optional spaces
3 participants