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

Structured Query Strings? #1

Open
JohnVinyard opened this issue Feb 22, 2019 · 1 comment
Open

Structured Query Strings? #1

JohnVinyard opened this issue Feb 22, 2019 · 1 comment

Comments

@JohnVinyard
Copy link
Collaborator

JohnVinyard commented Feb 22, 2019

def _query_without_id(uri):

I read your comments in _query_without_id(), and think you might be able to get away with passing keep_blank_values=True to urllib.parse.parse_qs().

I think this would make it possible to then start using your structured dictionary in the params parameter when you call session.post() instead of baking that in to the url itself.

@EdVinyard
Copy link
Owner

I need to improve the comment; there's a second difficulty I didn't document.

  1. The query string includes value-less items. E.g. color=&shape=. This can be solved just as you say.

  2. The query string includes semi-colons, but does not treat them (per the spec) as interchangeable with ampersand as query parameter delimiters. Rather, they are considered delimiters within the values. E.g. color=&flags=a;b;;;. I don't know how to solve this using parse_qs().

Here's an example:

    >>> parse_qs('color=&flags=a;b;;;', keep_blank_values=True)
    {'color': [''], 'flags': ['a'], 'b': ['']}

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

No branches or pull requests

2 participants