-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
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
Conversation
We should use the constants from aiohttp.hdrs package. We shouldn't have http related stuff in our repo if possible |
fd87128
to
24b9ff4
Compare
CONTENT_TYPE: "application/x-www-form-urlencoded; charset=UTF-8", | ||
HTTP_HEADER_X_REQUESTED_WITH: "XMLHttpRequest", | ||
REFERER: "http://{}/".format(self.host), | ||
CONNECTION: KEEP_ALIVE, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
e6710dc
to
ca7bccc
Compare
Description:
Use constants for HTTP headers across platforms.
Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass