public static final class HttpResponse.Builder extends Object implements AutoCloseable
Builder
for the HttpResponse
class.
Instances of HttpRequest.Builder
are created by calling HttpResponse#newBuilder
.
Constructor and Description |
---|
Builder(HttpResponse.Builder other) |
Modifier and Type | Method and Description |
---|---|
HttpResponse.Builder |
body(DataEntity body)
Sets the HTTP response content.
|
HttpResponse |
build()
Returns an
HttpResponse based on the properties set on this builder. |
void |
close() |
protected void |
finalize() |
HttpResponse.Builder |
header(HttpHeader header)
Sets the given http header to the set of headers for this response.
|
HttpResponse.Builder |
header(String name,
String value)
Sets the given name value pair to the set of headers for this response.
|
HttpResponse.Builder |
statusCode(int statusCode)
Sets the status code of the HTTP response.
|
public Builder(@NotNull HttpResponse.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public HttpResponse build() throws IllegalStateException
HttpResponse
based on the properties set on this builder.HttpResponse
.IllegalStateException
- if the status code for this response has not been set.@NotNull public HttpResponse.Builder statusCode(int statusCode)
This parameter is mandatory. If it is not set, HttpResponse.Builder#build
will throw an exception.
statusCode
- the status code for this response.@NotNull public HttpResponse.Builder body(@NotNull DataEntity body)
This parameter is optional.
body
- the response content.@NotNull public HttpResponse.Builder header(@NotNull String name, @NotNull String value)
name
- header namevalue
- header value@NotNull public HttpResponse.Builder header(@NotNull HttpHeader header)
header
- an HttpHeader
.