org.springframework.http.client
Class AbstractClientHttpRequest
java.lang.Object
org.springframework.http.client.AbstractClientHttpRequest
- All Implemented Interfaces:
- ClientHttpRequest, HttpMessage, HttpOutputMessage
- Direct Known Subclasses:
- CommonsClientHttpRequest, SimpleClientHttpRequest
public abstract class AbstractClientHttpRequest
- extends java.lang.Object
- implements ClientHttpRequest
Abstract base for ClientHttpRequest
that makes sure that headers and body are not written multiple times.
- Since:
- 3.0
- Author:
- Arjen Poutsma
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
executed
private boolean executed
headers
private final HttpHeaders headers
bufferedOutput
private final java.io.ByteArrayOutputStream bufferedOutput
AbstractClientHttpRequest
public AbstractClientHttpRequest()
getHeaders
public final HttpHeaders getHeaders()
- Description copied from interface:
HttpMessage
- Return the headers of this message.
- Specified by:
getHeaders
in interface HttpMessage
- Returns:
- a corresponding HttpHeaders object
getBody
public final java.io.OutputStream getBody()
throws java.io.IOException
- Description copied from interface:
HttpOutputMessage
- Return the body of the message as an output stream.
- Specified by:
getBody
in interface HttpOutputMessage
- Returns:
- the output stream body
- Throws:
java.io.IOException
- in case of I/O Errors
execute
public final ClientHttpResponse execute()
throws java.io.IOException
- Description copied from interface:
ClientHttpRequest
- Execute this request, resulting in a
ClientHttpResponse
that can be read.
- Specified by:
execute
in interface ClientHttpRequest
- Returns:
- the response result of the execution
- Throws:
java.io.IOException
- in case of I/O errors
checkExecuted
private void checkExecuted()
executeInternal
protected abstract ClientHttpResponse executeInternal(HttpHeaders headers,
byte[] bufferedOutput)
throws java.io.IOException
- Abstract template method that writes the given headers and content to the HTTP request.
- Parameters:
headers
- the HTTP headersbufferedOutput
- the body content
- Returns:
- the response object for the executed request
- Throws:
java.io.IOException