Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use constants for HTTP headers #10313

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

Merged
merged 3 commits into from
Nov 4, 2017
Merged

Use constants for HTTP headers #10313

merged 3 commits into from
Nov 4, 2017

Conversation

fabaff
Copy link
Member

@fabaff fabaff commented Nov 3, 2017

Description:

Use constants for HTTP headers across platforms.

Checklist:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@balloob
Copy link
Member

balloob commented Nov 3, 2017

We should use the constants from aiohttp.hdrs package. We shouldn't have http related stuff in our repo if possible

CONTENT_TYPE: "application/x-www-form-urlencoded; charset=UTF-8",
HTTP_HEADER_X_REQUESTED_WITH: "XMLHttpRequest",
REFERER: "http://{}/".format(self.host),
CONNECTION: KEEP_ALIVE,
Copy link
Member

Choose a reason for hiding this comment

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

There is no reason to move these to constants. They can just remain strings. All constants that are in const.py will be loaded into memory of every HASS instance so only common constants should make it into that file. So let's keep things like X_REQUESTED_WITH, KEEP_ALIVE and NO_CACHE in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I don't understand. Beside HTTP_HEADER_X_REQUESTED_WITH and NO_CACHE which are in const.py is the rest coming out of aiohttp.hdrs.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I meant that we shouldn't add any HTTP headers to const.py anymore.

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Ok to merge when last comment addressed and tests pass.

@balloob balloob merged commit de9d19d into dev Nov 4, 2017
@balloob balloob deleted the const-user-agent branch November 4, 2017 19:04
@balloob balloob mentioned this pull request Nov 17, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants