-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow gzip compression in high-level server response interface #403
Allow gzip compression in high-level server response interface #403
Conversation
Please fix pep8 errors |
Maybe |
Enum with 3 values? |
@fafhrd91 I believe enum is the perfect solution but we still should support |
Let's drop py3.3 support |
+1 |
@fafhrd91 you are moving too fast from my perspective. Anyway, how |
I prefer to use enum. Is flufl.enum compatible with py3.4 enums? |
It's fully compatible and it is the base library for standard |
Lets then just use enum |
Okay so based on this discussion here is a rough draft of what the new documentation might look like:
|
@danielnelson did you mean |
I'm not sure I understand. Are you saying you don't expect a |
I say |
I wouldn't worry about backward compatibility here. |
Sorry, but I do care about backward compatibility.
|
|
|
Anywhere I said transfer encoding above should definitely be content coding, and of course the header is Having backwards compatibility here wouldn't introduce too much cruft, and I also think we are not completely sure what we would need from a compress interface. So I would prefer to just add backwards compatibility for now. |
@@ -72,6 +77,11 @@ def content_length(self, _CONTENT_LENGTH=hdrs.CONTENT_LENGTH): | |||
FileField = collections.namedtuple('Field', 'name filename file content_type') | |||
|
|||
|
|||
class ContentCoding(enum.Enum): | |||
deflate = 1 |
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.
Please use str values: deflate = 'deflate'
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.
Also would like to note that this list of encodings is not complete. Never saw compress
in the wild, however, but identity
is pretty common one.
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.
I believe this is the current list of registered codings. I'll add a comment about how this is enum only represents our supported coding types.
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.
Good finding! Please add a comment with this link
I have updated the pull request with the suggested changes. |
LGTM |
…ression Allow gzip compression in high-level server response interface
Merged. @danielnelson thanks for patience :) |
Add encoding kwarg to enable_compression to select gzip or deflate and
set Content-Encoding header.
This is for issue #396.
I have a few concerns about this code:
I think that when using a high level interface one would generally want to simply enable all types of compression that are supported by the library, with selection automatically made based on the Accept-Encoding header. Potentially one may want to optionally specify a subset of the available encoding types, such as if we had compress support, maybe one would want to allow gzip and compress but not deflate.
I considered changing the signature to accept a sequence of encodings, however if we do this it is no longer intuitive to me how the
force
argument behaves.Let me know how you think it would best to proceed.