Partilhar via


HttpResponseMessage.Builder Interface

public static interface HttpResponseMessage.Builder

A builder to create an instance of HttpResponseMessage

Method Summary

Modifier and Type Method and Description
abstract Builder body(Object body)

Sets the body of the HTTP response.

abstract HttpResponseMessage build()

Creates an instance of HttpMessageResponse with the values configured in this builder.

abstract Builder header(String key, String value)

Adds a (key, value) header to the response.

abstract Builder status(HttpStatusType status)

Sets the status code to be used in the HttpResponseMessage object.

Method Details

body

public abstract HttpResponseMessage.Builder body(Object body)

Sets the body of the HTTP response.

Parameters:

body - The body of the HTTP response

Returns:

this builder

build

public abstract HttpResponseMessage build()

Creates an instance of HttpMessageResponse with the values configured in this builder.

Returns:

an HttpMessageResponse object

header

public abstract HttpResponseMessage.Builder header(String key, String value)

Adds a (key, value) header to the response.

Parameters:

key - The key of the header value.
value - The value of the header value.

Returns:

this builder

status

public abstract HttpResponseMessage.Builder status(HttpStatusType status)

Sets the status code to be used in the HttpResponseMessage object. You can provide standard HTTP Status using enum values from HttpStatus, or you can create a custom status code using custom(int code).

Parameters:

status - An HTTP status code representing the outcome of the HTTP request.

Returns:

this builder

Applies to