Package org.kohsuke.github.connector
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()
, andrequest()
will still be readable but it is recommended that consumers copy any information they need rather than retaining a reference toGitHubConnectorResponse
.- Author:
- Liam Newman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitHubConnectorResponse.ByteArrayResponse
A ByteArrayResponse class
-
Constructor Summary
Constructors Modifier Constructor Description protected
GitHubConnectorResponse(GitHubConnectorRequest request, int statusCode, Map<String,List<String>> headers)
GitHubConnectorResponse constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,List<String>>
allHeaders()
The headers for this response.abstract InputStream
bodyStream()
The response body as anInputStream
.String
header(String name)
Gets the value of a header field for this response.int
parseInt(String name)
Parse a header value as a signed decimal integer.GitHubConnectorRequest
request()
Gets theGitHubConnectorRequest
for this response.int
statusCode()
The status code for this response.HttpURLConnection
toHttpURLConnection()
Deprecated.This method is present only to provide backward compatibility with other deprecated components.protected InputStream
wrapStream(InputStream stream)
Handles wrapping the body stream if indicated by the "Content-Encoding" header.
-
-
-
Method Detail
-
toHttpURLConnection
@Deprecated @Nonnull public HttpURLConnection toHttpURLConnection()
Deprecated.This method is present only to provide backward compatibility with other deprecated components.Get this response as aHttpURLConnection
.- Returns:
- an object that implements at least the response related methods of
HttpURLConnection
.
-
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 anInputStream
.- Returns:
- the response body
- Throws:
IOException
- if response stream is null or an I/O Exception occurs.
-
request
@Nonnull public GitHubConnectorRequest request()
Gets theGitHubConnectorRequest
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.
-
-