Skip to content

Fix q=0 crash and ordering in get_choice_from_headers - #2415

Open
Shubham-Padkonde wants to merge 1 commit into
geopython:masterfrom
Shubham-Padkonde:fix/accept-header-q-ordering
Open

Shubham-Padkonde wants to merge 1 commit into
geopython:masterfrom
Shubham-Padkonde:fix/accept-header-q-ordering

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor
  • A header entry with q=0 (e.g. "Accept-Language: fr;q=0, en") raised ZeroDivisionError from 1 / q_value. q=0 means "not acceptable", so such entries are now skipped; if nothing acceptable remains, None is returned as for a missing header.
  • With all=True the choices were returned in heap order rather than sorted order, e.g. "a;q=0.1,b;q=0.2,c;q=0.3,d;q=0.4,e;q=0.9" gave ['e', 'd', 'b', 'a', 'c']. Choices are now sorted by descending q, keeping header order for ties.
  • An unparsable q value such as "q=1.2.3" is skipped instead of raising.

Overview

Related Issue / discussion

Additional information

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

- A header entry with q=0 (e.g. "Accept-Language: fr;q=0, en") raised
  ZeroDivisionError from 1 / q_value. q=0 means "not acceptable", so
  such entries are now skipped; if nothing acceptable remains, None is
  returned as for a missing header.
- With all=True the choices were returned in heap order rather than
  sorted order, e.g. "a;q=0.1,b;q=0.2,c;q=0.3,d;q=0.4,e;q=0.9" gave
  ['e', 'd', 'b', 'a', 'c']. Choices are now sorted by descending q,
  keeping header order for ties.
- An unparsable q value such as "q=1.2.3" is skipped instead of raising.

This branch has not been deployed

No deployments
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.

1 participant