Class BufferedHttpResponse
- java.lang.Object
-
- com.azure.android.core.http.HttpResponse
-
- com.azure.android.core.http.implementation.BufferedHttpResponse
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class BufferedHttpResponse extends HttpResponse
HTTP response which will buffer the response's body.
-
-
Constructor Summary
Constructors Constructor Description BufferedHttpResponse(HttpResponse innerHttpResponse)
Creates a buffered HTTP response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BufferedHttpResponse
buffer()
Get a new Response object wrapping this response with it's content buffered into memory.void
close()
Closes the response content stream, if any.java.io.InputStream
getBody()
Get theInputStream
producing response content chunks.byte[]
getBodyAsByteArray()
Get the response content as a byte[].java.lang.String
getBodyAsString()
Get the response content as a string.java.lang.String
getBodyAsString(java.nio.charset.Charset charset)
Get the response content as a string.HttpHeaders
getHeaders()
Get all response headers.java.lang.String
getHeaderValue(java.lang.String name)
Lookup a response header with the provided name.int
getStatusCode()
Get the response status code.-
Methods inherited from class com.azure.android.core.http.HttpResponse
getRequest
-
-
-
-
Constructor Detail
-
BufferedHttpResponse
public BufferedHttpResponse(HttpResponse innerHttpResponse)
Creates a buffered HTTP response.- Parameters:
innerHttpResponse
- The HTTP response to buffer.
-
-
Method Detail
-
getStatusCode
public int getStatusCode()
Description copied from class:HttpResponse
Get the response status code.- Specified by:
getStatusCode
in classHttpResponse
- Returns:
- the response status code
-
getHeaderValue
public java.lang.String getHeaderValue(java.lang.String name)
Description copied from class:HttpResponse
Lookup a response header with the provided name.- Specified by:
getHeaderValue
in classHttpResponse
- Parameters:
name
- the name of the header to lookup.- Returns:
- the value of the header, or null if the header doesn't exist in the response.
-
getHeaders
public HttpHeaders getHeaders()
Description copied from class:HttpResponse
Get all response headers.- Specified by:
getHeaders
in classHttpResponse
- Returns:
- the response headers
-
getBody
public java.io.InputStream getBody()
Description copied from class:HttpResponse
Get theInputStream
producing response content chunks.- Specified by:
getBody
in classHttpResponse
- Returns:
- The response's content as a stream.
-
getBodyAsByteArray
public byte[] getBodyAsByteArray()
Description copied from class:HttpResponse
Get the response content as a byte[].- Specified by:
getBodyAsByteArray
in classHttpResponse
- Returns:
- this response content as a byte[]
-
getBodyAsString
public java.lang.String getBodyAsString()
Description copied from class:HttpResponse
Get the response content as a string.- Specified by:
getBodyAsString
in classHttpResponse
- Returns:
- This response content as a string
-
getBodyAsString
public java.lang.String getBodyAsString(java.nio.charset.Charset charset)
Description copied from class:HttpResponse
Get the response content as a string.- Specified by:
getBodyAsString
in classHttpResponse
- Parameters:
charset
- the charset to use as encoding- Returns:
- This response content as a string
-
buffer
public BufferedHttpResponse buffer()
Description copied from class:HttpResponse
Get a new Response object wrapping this response with it's content buffered into memory.- Overrides:
buffer
in classHttpResponse
- Returns:
- the new Response object
-
close
public void close()
Description copied from class:HttpResponse
Closes the response content stream, if any.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classHttpResponse
-
-