java.lang.Object
org.kohsuke.github.connector.GitHubConnectorResponse
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
GitHubConnectorResponse.ByteArrayResponse
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A ByteArrayResponse class -
Constructor Summary
ModifierConstructorDescriptionprotected
GitHubConnectorResponse
(GitHubConnectorRequest request, int statusCode, Map<String, List<String>> headers) GitHubConnectorResponse constructor -
Method Summary
Modifier and TypeMethodDescriptionThe headers for this response.abstract InputStream
The response body as anInputStream
.Gets the value of a header field for this response.final int
Parse a header value as a signed decimal integer.request()
Gets theGitHubConnectorRequest
for this response.int
The status code for this response.protected InputStream
wrapStream
(InputStream stream) Handles wrapping the body stream if indicated by the "Content-Encoding" header.
-
Constructor Details
-
GitHubConnectorResponse
protected GitHubConnectorResponse(@Nonnull GitHubConnectorRequest request, int statusCode, @Nonnull Map<String, List<String>> headers) GitHubConnectorResponse constructor- Parameters:
request
- the requeststatusCode
- the status codeheaders
- the headers
-
-
Method Details
-
header
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
The response body as anInputStream
.- Returns:
- the response body
- Throws:
IOException
- if response stream is null or an I/O Exception occurs.
-
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
The headers for this response.- Returns:
- the headers for this response.
-
wrapStream
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
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.
-