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

Replace Net::HTTP to a faster HTTP client. #15

Closed
prodis opened this issue Mar 18, 2017 · 12 comments
Closed

Replace Net::HTTP to a faster HTTP client. #15

prodis opened this issue Mar 18, 2017 · 12 comments

Comments

@prodis
Copy link
Owner

prodis commented Mar 18, 2017

Some options:

Benchmark example: https://github.com/mrsimo/ruby-http-clients

@prodis
Copy link
Owner Author

prodis commented Mar 18, 2017

Take in account log options.

@prodis prodis changed the title Replace Net::HTTP by a faster HTTP client. Replace Net::HTTP to a faster HTTP client. Mar 19, 2018
@mateusluizfb
Copy link
Contributor

May I pick this one?

@prodis
Copy link
Owner Author

prodis commented Oct 8, 2018

@mateusluizfb Yes, you may!

My current choice is HTTP (https://github.com/httprb/http), mainly because Typhoeus has not been updated. Besides, the maintainers of HTTP are working on version 4 that includes good support for logging: httprb/http#499.

For now we can keep Correios CEP logs as we have.

Thanks.

@mateusluizfb
Copy link
Contributor

If you want to see how the things are going https://github.com/mateusluizfb/correios-cep/tree/feature/change-http-client

@mateusluizfb
Copy link
Contributor

@prodis the logging feature that you linked it's not released in the stable version, do you mind wait until it's done?

@prodis
Copy link
Owner Author

prodis commented Oct 14, 2018

@mateusluizfb For now just replace Net::Http to http.rb using the same logging we have.

When the version of http.rb supporting logging is available, we update correios-cep again.

@mateusluizfb
Copy link
Contributor

Ok

@prodis
Copy link
Owner Author

prodis commented Oct 15, 2018

@mateusluizfb
HTTP v4.0.0 has been released! 🎊
https://rubygems.org/gems/http/versions/4.0.0

require 'http'
require 'logger'

HTTP.use(logging: { logger: Logger.new(STDOUT) }).get('http://httpbin.org/get')
# => #<HTTP::Response/1.1 200 OK {"Connection"=>"close", "Server"=>"gunicorn/19.9.0", "Date"=>"Mon, 15 Oct 2018 22:17:31 GMT", "Content-Type"=>"application/json", "Content-Length"=>"194", "Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Credentials"=>"true", "Via"=>"1.1 vegur"}>
I, [2018-10-16T00:17:30.976815 #33276]  INFO -- : > GET http://httpbin.org/get
D, [2018-10-16T00:17:30.976885 #33276] DEBUG -- : Connection: close
Host: httpbin.org
User-Agent: http.rb/4.0.0


I, [2018-10-16T00:17:31.227332 #33276]  INFO -- : < 200 OK
D, [2018-10-16T00:17:31.227549 #33276] DEBUG -- : Connection: close
Server: gunicorn/19.9.0
Date: Mon, 15 Oct 2018 22:17:31 GMT
Content-Type: application/json
Content-Length: 194
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Via: 1.1 vegur

{
  "args": {},
  "headers": {
    "Connection": "close",
    "Host": "httpbin.org",
    "User-Agent": "http.rb/4.0.0"
  },
  "origin": "213.127.85.32",
  "url": "http://httpbin.org/get"
}

@mateusluizfb
Copy link
Contributor

Nice!!! The PR is practically done then!

@mateusluizfb
Copy link
Contributor

Here's the PR #20

I'm also ran the rubocop in the code and found 68 offenses, do you mind if I open another PR fixing the offenses?

@prodis
Copy link
Owner Author

prodis commented Nov 18, 2018

@mateusluizfb Thank you for your contribution!

@prodis
Copy link
Owner Author

prodis commented Nov 18, 2018

Released on version 0.7.0.

@prodis prodis closed this as completed Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants