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

Header variable is always used, even when default is None #167

Closed
liiight opened this issue Jul 18, 2019 · 0 comments · Fixed by #169
Closed

Header variable is always used, even when default is None #167

liiight opened this issue Jul 18, 2019 · 0 comments · Fixed by #169
Milestone

Comments

@liiight
Copy link

liiight commented Jul 18, 2019

Describe the bug
When using the Header type for a variable, it is always added to the request, even if the default of None is used

To Reproduce

import uplink


class HTTPBin(uplink.Consumer):

    @uplink.returns.json
    @uplink.get('headers')
    def headers(self, foo: uplink.Header = None):
        pass


bin = HTTPBin(base_url='https://httpbin.org')
print(bin.headers())

Result: {'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Foo': 'None', 'Host': 'httpbin.org', 'User-Agent': 'python-requests/2.20.1'}}

Expected behavior
When the default value of None is used, the header should not be added to the request, as that is the expected behavior. It is also how Query works and it should be consistent.

@prkumar prkumar added this to the v0.10.0 milestone Aug 10, 2019
prkumar added a commit that referenced this issue Aug 10, 2019
prkumar added a commit that referenced this issue Aug 10, 2019
prkumar added a commit that referenced this issue Aug 10, 2019
@prkumar prkumar mentioned this issue Feb 8, 2020
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 a pull request may close this issue.

2 participants