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

Auto-deflate injects Content-Encoding even wihtout body #521

Closed
ixti opened this issue Jan 20, 2019 · 4 comments
Closed

Auto-deflate injects Content-Encoding even wihtout body #521

ixti opened this issue Jan 20, 2019 · 4 comments
Labels

Comments

@ixti
Copy link
Member

ixti commented Jan 20, 2019

Example:

require "http"
require "logger"

HTTP.use(:logging => { :logger => Logger.new(STDOUT) })
  .use(:auto_deflate)
  .get("https://example.com")

The above will send request:

GET https://example.com/
Connection: close
Content-Encoding: gzip
Host: example.com
User-Agent: http.rb/4.0.3

Content-Encoding is being sent as gzip, while there's no content at all. That makes some servers go nuts. E.g. I've seen 403 responses, while example.com responds with 400 (which I believe is correct response if it needs to be failed)

@ixti ixti added the Bug label Jan 20, 2019
@ixti
Copy link
Member Author

ixti commented Jan 20, 2019

/cc @Bonias

@ixti
Copy link
Member Author

ixti commented Jan 20, 2019

Another problem I encounter, which worth keeping in mind that some servers may respond with (!) 400 error when there's body and no content-length header, which is not present when auto-deflate is in use.

Bonias pushed a commit to Bonias/http that referenced this issue Feb 12, 2019
Fixes httprb#521

Also move auto-deflate related code from `http/client.rb` to `http/features/auto_deflate.rb`
which seems to be move appropriate place.
Bonias pushed a commit to Bonias/http that referenced this issue Feb 12, 2019
Fixes httprb#521

Also move auto-deflate related code from `http/client.rb` to `http/features/auto_deflate.rb`
which seems to be move appropriate place.
Bonias pushed a commit to Bonias/http that referenced this issue Feb 12, 2019
Fixes httprb#521

Also move auto-deflate related code from `http/client.rb` to `http/features/auto_deflate.rb`
which seems to be move appropriate place.
@Bonias
Copy link
Contributor

Bonias commented Feb 12, 2019

Content-Encoding is being sent as gzip, while there's no content at all

Fixed in #529


when there's body and no content-length header, which is not present when auto-deflate is in use

Can you provide an example? Content-Length is set when auto-deflate is in use:

HTTP.use(logging: { logger: Logger.new(STDOUT) }).
  use(:auto_deflate).
  post("http://localhost:3000", body: 'xxx')

Here is what is logged by logger:

I, [2019-02-12T21:46:37.062172 #52955]  INFO -- : > POST http://localhost:3000/
D, [2019-02-12T21:46:37.062277 #52955] DEBUG -- : Connection: close
Content-Encoding: gzip
Host: localhost:3000
User-Agent: http.rb/5.0.0.pre

xxx

and here is what is actually sent:

POST / HTTP/1.1
Connection: close
Content-Encoding: gzip
Host: localhost:3000
User-Agent: http.rb/5.0.0.pre
Content-Length: 23

�0c\���
�

@ixti
Copy link
Member Author

ixti commented Feb 12, 2019

Thank for the fix. About Content-Length with body, indeed, I have overlooked that it's simply not being logged, so my problem was surely related to something else. Thanks again for looking into this.

@ixti ixti closed this as completed in #529 Feb 12, 2019
ixti pushed a commit that referenced this issue Feb 12, 2019
Fixes #521

Also move auto-deflate related code from `http/client.rb` to `http/features/auto_deflate.rb`
which seems to be move appropriate place.
ixti pushed a commit that referenced this issue Feb 12, 2019
Fixes #521

Also move auto-deflate related code from `http/client.rb` to `http/features/auto_deflate.rb`
which seems to be move appropriate place.
@ixti ixti changed the title Auro-deflate injects Content-Encoding even wihtout body Auto-deflate injects Content-Encoding even wihtout body Feb 12, 2019
@tarcieri tarcieri mentioned this issue May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants