Class GitHubConnectorResponse

java.lang.Object
org.kohsuke.github.connector.GitHubConnectorResponse
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
GitHubConnectorResponse.ByteArrayResponse

public abstract class GitHubConnectorResponse extends Object implements Closeable
Response information supplied when a response is received and before the body is processed.

Instances of this class are closed once the response is done being processed. This means that bodyStream() will not be readable after a call is completed. statusCode(), allHeaders(), and request() will still be readable but it is recommended that consumers copy any information they need rather than retaining a reference to GitHubConnectorResponse.

Author:
Liam Newman
  • Constructor Details

    • GitHubConnectorResponse

      protected GitHubConnectorResponse(@Nonnull GitHubConnectorRequest request, int statusCode, @Nonnull Map<String,List<String>> headers)
      GitHubConnectorResponse constructor
      Parameters:
      request - the request
      statusCode - the status code
      headers - the headers
  • Method Details

    • header

      @CheckForNull public String header(String name)
      Gets the value of a header field for this response.
      Parameters:
      name - the name of the header field.
      Returns:
      the value of the header field, or null if the header isn't set.
    • bodyStream

      @Nonnull public abstract InputStream bodyStream() throws IOException
      The response body as an InputStream.
      Returns:
      the response body
      Throws:
      IOException - if response stream is null or an I/O Exception occurs.
    • request

      @Nonnull public GitHubConnectorRequest request()
      Gets the GitHubConnectorRequest for this response.
      Returns:
      the GitHubConnectorRequest for this response.
    • statusCode

      public int statusCode()
      The status code for this response.
      Returns:
      the status code for this response.
    • allHeaders

      @Nonnull public Map<String,List<String>> allHeaders()
      The headers for this response.
      Returns:
      the headers for this response.
    • wrapStream

      protected InputStream wrapStream(InputStream stream) throws IOException
      Handles wrapping the body stream if indicated by the "Content-Encoding" header.
      Parameters:
      stream - the stream to possibly wrap
      Returns:
      an input stream potentially wrapped to decode gzip input
      Throws:
      IOException - if an I/O Exception occurs.
    • parseInt

      public final int parseInt(String name) throws NumberFormatException
      Parse a header value as a signed decimal integer.
      Parameters:
      name - the header field to parse
      Returns:
      integer value of the header field
      Throws:
      NumberFormatException - if the header is missing or does not contain a parsable integer.