Package org.springframework.http.server

# Class DelegatingServerHttpResponse

java.lang.Object
org.springframework.http.server.DelegatingServerHttpResponse

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`, `HttpMessage`, `HttpOutputMessage`, `ServerHttpResponse`

public class DelegatingServerHttpResponse extends Object implements ServerHttpResponse
Implementation of `ServerHttpResponse` that delegates all calls to a given target `ServerHttpResponse`.

Since:
  5.3.2
Author:
  Arjen Poutsma

## Constructor Summary

Constructors
Constructor
Description
`DelegatingServerHttpResponse(ServerHttpResponse delegate)`
Create a new `DelegatingServerHttpResponse`.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Close this response, freeing any resources created.
`void`
`flush()`
Ensure that the headers and the content of the response are written out.
`OutputStream`
`getBody()`
Return the body of the message as an output stream.
`ServerHttpResponse`
`getDelegate()`
Returns the target response that this response delegates to.
`HttpHeaders`
`getHeaders()`
Return the headers of this message.
`void`
`setStatusCode(HttpStatusCode status)`
Set the HTTP status code of the response.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DelegatingServerHttpResponse

public DelegatingServerHttpResponse(ServerHttpResponse delegate)
Create a new `DelegatingServerHttpResponse`.

Parameters:
  `delegate` - the response to delegate to

## Method Details

### getDelegate

public ServerHttpResponse getDelegate()
Returns the target response that this response delegates to.

Returns:
  the delegate

### setStatusCode

public void setStatusCode(HttpStatusCode status)
Description copied from interface: `ServerHttpResponse`
Set the HTTP status code of the response.

Specified by:
  `setStatusCode` in interface `ServerHttpResponse`
Parameters:
  `status` - the HTTP status as an HttpStatus enum value

### flush

public void flush() throws IOException
Description copied from interface: `ServerHttpResponse`
Ensure that the headers and the content of the response are written out.

After the first flush, headers can no longer be changed. Only further content writing and content flushing is possible.

Specified by:
  `flush` in interface `Flushable`
Specified by:
  `flush` in interface `ServerHttpResponse`
Throws:
  `IOException`

### close

public void close()
Description copied from interface: `ServerHttpResponse`
Close this response, freeing any resources created.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `ServerHttpResponse`

### getBody

public OutputStream getBody() throws 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 (never `null`)
Throws:
  `IOException` - in case of I/O errors

### getHeaders

public HttpHeaders getHeaders()
Description copied from interface: `HttpMessage`
Return the headers of this message.

Specified by:
  `getHeaders` in interface `HttpMessage`
Returns:
  a corresponding HttpHeaders object (never `null`)