-
Notifications
You must be signed in to change notification settings - Fork 321
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
Avoid a dependency cycle between Client and Connection classes. #353
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I found out that sometimes you can get this error when using the gem: from /.../gems/http-2.0.1/lib/http.rb:8:in `<top (required)>' from /.../gems/http-2.0.1/lib/http.rb:8:in `require' from /.../gems/http-2.0.1/lib/http/client.rb:7:in `<top (required)>' from /.../gems/http-2.0.1/lib/http/client.rb:7:in `require' from /.../gems/http-2.0.1/lib/http/connection.rb:4:in `<top (required)>' from /.../gems/http-2.0.1/lib/http/connection.rb:4:in `require' The problem was that 'http.rb' was requiring 'http/client.rb' that at the same time was requiring 'http/connection.rb' which was requiring 'http/client.rb' again. I think that in general is not very good to have a cycle like this in the dependency graph of the code, so I decided to remove that dependency by moving the constants KEEP_ALIVE and CLOSE to the Connection class. This way Connection is now independent from Client. Maybe this constants could go to another module but I couldn't think in a better place.
👍 Thank you! |
That was fast. Thanks 😄 |
@ixti Hi! |
Sorry for delay. |
@ixti thank you for your work! |
jsonn
pushed a commit
to jsonn/pkgsrc
that referenced
this pull request
Oct 18, 2016
## 2.0.3 (2016-08-03) * [#365](httprb/http#365) Add `HTTP::Response#content_length` ([@janko-m]) * [#335](httprb/http#335), [#360](httprb/http#360) Set `Content-Length: 0` header for `nil` bodies. ([@britishtea]) ## 2.0.2 (2016-06-24) * [#353](httprb/http#353) Avoid a dependency cycle between Client and Connection classes. ([@jhbabon]) ## 2.0.1 (2016-05-12) * [#341](httprb/http#341) Refactor some string manipulations so they are more performant (up to 3-4x faster) and more concise. ([@tonyta]) * [#339](httprb/http#341) Always use byte methods when writing/slicing the write buffer. ([@zanker]) ## 2.0.0 (2016-04-23) * [#333](httprb/http#333) Fix HTTPS request headline when sent via proxy. ([@Connorhd]) * [#331](httprb/http#331) Add `#informational?`, `#success?`, `#redirect?`, `#client_error?` and `#server_error?` helpers to `Response::Status`. ([@mwitek]) * [#330](httprb/http#330) Support custom CONNECT headers (request/response) during HTTPS proxy requests. ([@smudge]) * [#319](httprb/http#319) Drop Ruby 1.9.x support. ([@ixti]) ## 1.0.4 (2016-03-19) * [#320](httprb/http#320) Fix timeout regression. ([@tarcieri]) ## 1.0.3 (2016-03-16) * [#314](httprb/http#314) Validate charset before forcing encoding. ([@kylekyle]) * [#318](httprb/http#318) Remove redundant string allocations upon header names normalization. ([@ixti])
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found out that sometimes you can get this error when using the gem:
The problem was that
http.rb
was requiringhttp/client.rb
that at the same time was requiringhttp/connection.rb
which was requiringhttp/client.rb
again.I think that in general is not very good to have a cycle like this in the dependency graph of the code, so I decided to remove that dependency by moving the constants
KEEP_ALIVE
andCLOSE
to the Connection class. This way Connection is now independent from Client.Maybe this constants could go to another module but I couldn't think in a better place.