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

Convert library to use built-in Net::HTTP #813

Merged
merged 1 commit into from
Jul 29, 2019

Commits on Jul 29, 2019

  1. Convert library to use built-in Net::HTTP

    Moves the library off of Faraday and over onto the standard library's
    built-in `Net::HTTP` module. The upside of the transition is that we
    break away from a few dependencies that have caused us a fair bit of
    trouble in the past, the downside is that we need more of our own code
    to do things (although surprisingly, not that much more).
    
    The biggest new pieces are:
    
    * `ConnectionManager`: A per-thread class that manages a connection to
      each Stripe infrastructure URL (like `api.stripe.com`,
      `connect.stripe.com`, etc.) so that we can reuse them between
      requests. It's also responsible for setting up and configuring new
      `Net::HTTP` connections, which is a little more heavyweight
      code-wise compared to other libraries. All of this could have lived in
      `StripeClient`, but I extracted it because that class has gotten so
      big.
    
    * `MultipartEncoder`: A class that does multipart form encoding for file
      uploads. Unfortunately, Ruby doesn't bundle anything like this. I
      built this by referencing the Go implementation because the original
      RFC is not very detailed or well-written. I also made sure that it was
      behaving similarly to our other custom implementations like
      stripe-node, and that it can really upload a file outside the test
      suite.
    
    There's some risk here in that it's easy to miss something across one of
    these big transitions. I've tried to test out various error cases
    through tests, but also by leaving scripts running as I terminate my
    network connection and bring it back. That said, we'd certainly release
    on a major version bump because some of the interface (like setting
    `Stripe.default_client`) changes.
    brandur committed Jul 29, 2019
    Configuration menu
    Copy the full SHA
    140c727 View commit details
    Browse the repository at this point in the history