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

Fix qfactor rankings for HTTP-ACCEPT #340

Merged
merged 3 commits into from Feb 11, 2018

Conversation

urbandove
Copy link
Contributor

Currently qfactor is being parsed - and they are ordered in order of preference - but when i comes time to check if to show html vs json it just checks if either of them exist and then show html if html exists in the list of accepted headers and json doesn't - instead of figuring out what's the first in the list.
Also - when splitting multiple accepted headers it leaves a space in front of the second one and on - so I've added a .strip()

Also added tests

@coveralls
Copy link

coveralls commented Dec 12, 2017

Coverage Status

Coverage decreased (-0.3%) to 92.843% when pulling 6008cb6 on urbandove:qfactor into 24706f5 on graphql-python:master.

Copy link
Contributor

@spockNinja spockNinja left a comment

Choose a reason for hiding this comment

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

Thanks a bunch! Just one minor naming suggestion for some extra clarity.

The Travis build is currently broken and waiting on #338. Once that is in, we can re-run Travis and get this moving on.

accepted_length = len(accepted)
#the list will be ordered in preferred first - so we have to make
#sure the most preferred gets the highest number
html_index = accepted_length - accepted.index('text/html') if 'text/html' in accepted else 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, count is definitely not accounting for priority here. Thanks for the fix.

Can we rename html_index and json_index to html_priority and json_priority? I was a little confused at first because their index wouldn't need accepted_length. But I now see why we need the accepted_length - accepted.index(... part to make the html_priority > json_priority condition work.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good Point - the names were leftovers from before the fixes - I have updated the names

@coveralls
Copy link

coveralls commented Dec 17, 2017

Coverage Status

Coverage increased (+0.3%) to 93.456% when pulling 6da95d7 on urbandove:qfactor into 24706f5 on graphql-python:master.

@coveralls
Copy link

coveralls commented Dec 18, 2017

Coverage Status

Coverage increased (+0.3%) to 93.456% when pulling 28cccb4 on urbandove:qfactor into 24706f5 on graphql-python:master.

@spockNinja
Copy link
Contributor

@syrusakbary This PR looks good to me, and is ready for your approval/merge.

@syrusakbary syrusakbary merged commit dbd3957 into graphql-python:master Feb 11, 2018
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.

None yet

4 participants