- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.5k
Support for deflate compression #360
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
| @rymis, thank you for the pull request. Could you explain more about "because some clients could compress content with GZip and to set deflate compression instead of correct gzip"? I would like to stick to the HTML spec unless the behavior is a widely accepted common practice. Thanks! | 
| Sorry, I thought a little and realized, I was wrong. I read that some client library was sending incorrect Content-Encoding somewhere on stackoverflow, but I think it is not wise to support this behavior. I'll fix the MR to be standard complient. The actual RFC looks like:  | 
        
          
                httplib.h
              
                Outdated
          
        
      | strm.opaque = Z_NULL; | ||
|  | ||
| // 15 is the value of wbits, which should be at the maximum possible value | ||
| // to ensure that any gzip stream can be decoded. The offset of 16 specifies | 
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.
Since '32' is now used for the automatic stream type detection, this comment ("The offset of 16 specifies...") is no longer valid. Could you update it?
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.
Yes, for sure
| @rymis, I checked the revised code and looks good to me except the comment for  | 
| Also one more request. Could you squash all the commits into a commit, so that the commit history could be simpler? | 
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 the comment for inflateInit2 should be like this:
    // 15 is the value of wbits, which should be at the maximum possible value
    // to ensure that any gzip stream can be decoded. The offset of 32 specifies
    // that the stream type should be automatically detected either gzip or deflate.
    is_valid_ = inflateInit2(&strm, 32 + 15) == Z_OK;	 
Also I just wonder why the unit test case GetMethod200withPercentEncoding  sneaked in...
| It's because of squashing of commits. It came from master :( I'll change the comment. | 
| Actually I can squash the commits on my side. Thanks for the adjustments. | 
| I have just merged it into the master. Thanks for your contribution! | 
| Thanks! | 
As long as httplib has gzip support it is easy to add deflate. I did it with automatic encoding detection because some clients could compress content with GZip and to set deflate compression instead of correct gzip.
As a discussion starting point, I'd like to add ContentTranscoder abstraction to encode and decode custom streams, like LZ4, Snappy, etc.