All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.stripe.net.StripeResponseStream Maven / Gradle / Ivy

There is a newer version: 28.1.0-beta.3
Show newest version
package com.stripe.net;

import com.stripe.util.StreamUtils;
import java.io.IOException;
import java.io.InputStream;

public class StripeResponseStream extends AbstractStripeResponse {
  /**
   * Initializes a new instance of the {@link StripeResponseStream} class.
   *
   * @param code the HTTP status code of the response
   * @param headers the HTTP headers of the response
   * @param body streaming body response
   * @throws NullPointerException if {@code headers} or {@code body} is {@code null}
   */
  public StripeResponseStream(int code, HttpHeaders headers, InputStream body) {
    super(code, headers, body);
  }

  /**
   * Buffers the entire response body into a string, constructing the appropriate StripeResponse
   *
   * @return the StripeResponse
   */
  StripeResponse unstream() throws IOException {
    final String bodyString = StreamUtils.readToEnd(this.body, ApiResource.CHARSET);
    this.body.close();
    return new StripeResponse(this.code, this.headers, bodyString);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy