Skip to content

Add HttpContent class#896

Merged
ob-stripe merged 1 commit intointegration-client-refactorfrom
ob-http-content
Nov 12, 2019
Merged

Add HttpContent class#896
ob-stripe merged 1 commit intointegration-client-refactorfrom
ob-http-content

Conversation

@ob-stripe
Copy link
Contributor

r? @brandur-stripe @richardm-stripe
cc @stripe/api-libraries

This PR:

  • adds a new HttpContent class that represents an HTTP request's content, i.e. the body and the Content-Type header (which can depend on the body, e.g. for multipart requests the header contains the boundary used to separate fields in the body).
  • adds a new FormEncoder.createHttpContent() method that builds and returns an HttpContent instance as needed (automatically choosing between form-data encoding and multipart encoding depending on whether all the parameters are strings or not)
  • removes the now useless FormEncoder.encodeMultipartParams() method
  • updates HttpURLConnectionClient to use HttpContent. The resulting code is a little bit weird, but will be refactored in a future PR
  • updates MultipartProcessor to write to a provided OutputStream instead of directly to a connection's OutputStream
  • removes the MultipartProcessor.getBoundary() method (the boundary is now initialized by HttpContent, and is a random UUIDv4 unless explicitly provided)
  • adds a bunch of tests to ensure the encoding is working as expected.

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Beautiful tests. Left one comment.

I was just thinking about whether stripe-java is "good", and after many many years of an obvious "no", at some point in the last year we crossed the threshold into a pretty definitive "yes". Nice work.

ptal @ob-stripe

@ob-stripe ob-stripe merged commit c00ca34 into integration-client-refactor Nov 12, 2019
@ob-stripe ob-stripe deleted the ob-http-content branch November 12, 2019 20:01
ob-stripe added a commit that referenced this pull request Nov 15, 2019
ob-stripe added a commit that referenced this pull request Nov 16, 2019
ob-stripe added a commit that referenced this pull request Dec 10, 2019
ob-stripe added a commit that referenced this pull request Dec 23, 2019
ob-stripe added a commit that referenced this pull request Jan 11, 2020
ob-stripe added a commit that referenced this pull request Jan 14, 2020
ob-stripe added a commit that referenced this pull request Jan 14, 2020
ob-stripe added a commit that referenced this pull request Jan 15, 2020
ob-stripe added a commit that referenced this pull request Jan 15, 2020
ob-stripe added a commit that referenced this pull request Jan 15, 2020
* Refactor form encoding

* Refactor request telemetry

* Move HTTP request methods into new `HttpClient` class

* Add `StripeRequest` object

* Add `HttpClient` abstract class

* Stop disabling the DNS cache

* Fix deprecation warnings (#895)

* Add HttpContent class (#896)

* Add Stopwatch class (#897)

* Move all request properties in `StripeRequest` (#898)

* Remove ApiResource.RequestType (#899)

* Add support for automatic request retries (#900)

* Minor fixes (#902)

* `StringUtils` class & better API key validation (#928)

* Remove support for custom `URLStreamHandler` (#927)

* Refactor HTTP headers handling (#931)

* Add `CaseInsensitiveMap` class

* Add `HttpHeaders` class

* Use `HttpHeaders` in `StripeRequest`

* Use `HttpHeaders` in `StripeResponse`

* Address review comments

* Modernize `StripeResponse` (#932)

* Add `maxNetworkRetries` as a global and per-request setting (#934)

* Add `StreamUtils` class (#935)

* Remove support for `count` and `total_count` in list objects (#936)

* Codegen for openapi e07de1a (#938)

* Update README (#939)

Co-authored-by: remi-stripe <remi@stripe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants