Package com.github.scribejava.core.model
Class Response
java.lang.Object
com.github.scribejava.core.model.Response
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class Response
extends java.lang.Object
implements java.io.Closeable
-
Constructor Summary
Constructors Constructor Description Response(int code, java.lang.String message, java.util.Map<java.lang.String,java.lang.String> headers, java.io.InputStream stream, java.io.Closeable... closeables)Response(int code, java.lang.String message, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body) -
Method Summary
Modifier and Type Method Description voidclose()java.lang.StringgetBody()Returns the response body as a string, closing the stream that backs it.intgetCode()Obtains the HTTP status codejava.lang.StringgetHeader(java.lang.String name)Obtains a single HTTP Header value, or null if undefinedjava.util.Map<java.lang.String,java.lang.String>getHeaders()Obtains aMapcontaining the HTTP Response Headersjava.lang.StringgetMessage()Obtains the HTTP status message.java.io.InputStreamgetStream()Obtains the meaningful stream of the HttpUrlConnection, either inputStream or errorInputStream, depending on the status codebooleanisSuccessful()java.lang.StringtoString()
-
Constructor Details
-
Response
public Response(int code, java.lang.String message, java.util.Map<java.lang.String,java.lang.String> headers, java.io.InputStream stream, java.io.Closeable... closeables) -
Response
public Response(int code, java.lang.String message, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)
-
-
Method Details
-
isSuccessful
public boolean isSuccessful() -
getBody
public java.lang.String getBody() throws java.io.IOExceptionReturns the response body as a string, closing the stream that backs it. Idempotent.- Returns:
- body as string
- Throws:
java.io.IOException- IO Exception
-
getStream
public java.io.InputStream getStream()Obtains the meaningful stream of the HttpUrlConnection, either inputStream or errorInputStream, depending on the status code- Returns:
- input stream / error stream
-
getCode
public int getCode()Obtains the HTTP status code- Returns:
- the status code
-
getMessage
public java.lang.String getMessage()Obtains the HTTP status message. Returnsnullif the message can not be discerned from the response (not valid HTTP)- Returns:
- the status message
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()Obtains aMapcontaining the HTTP Response Headers- Returns:
- headers
-
getHeader
public java.lang.String getHeader(java.lang.String name)Obtains a single HTTP Header value, or null if undefined- Parameters:
name- the header name.- Returns:
- header value or null.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-