Defines HTTP response.
A response is created using one of its factory methods, or you can start with a ResponseStatus and build from there.
import scala.language.implicitConversions
import scamper.http.{ BodyParser, Header, stringToEntity }
import scamper.http.ResponseStatus.Registry.Ok
val response = Ok("There is an answer.").setHeaders(
Header("Content-Type: text/plain"),
Header("Connection: close")
)
printf("Status Code: %d%n", response.statusCode)
printf("Reason Phrase: %s%n", response.reasonPhrase)
response.headers.foreach(println)
val contentType: Option[String] = response.getHeaderValue("Content-Type")
given BodyParser[String] = BodyParser.string()
printf("Body: %s%n", response.as[String])
- See also
- Companion
- object
Type members
Types
Value members
Concrete methods
Inherited methods
Creates message with additional headers.
Creates message with additional headers.
- Value Params
- more
additional message headers
- one
message header
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with additional headers.
Creates message with additional headers.
- Value Params
- headers
message headers
- Returns
new message
- Inherited from
- MessageBuilder
Gets message body as instance of T
.
Gets message body as instance of T
.
- Value Params
- parser
body parser
- Inherited from
- HttpMessage
Gets message attributes.
Gets message attributes.
- Note
Attributes are arbitrary values associated with message and are not part of transmitted message.
- Inherited from
- HttpMessage
Gets attribute value with given name.
Gets attribute value with given name.
- Value Params
- name
attribute name
- Inherited from
- HttpMessage
Gets attribute value with given name, or returns default if attribute not present.
Gets attribute value with given name, or returns default if attribute not present.
- Value Params
- default
default value
- name
attribute name
- Inherited from
- HttpMessage
Gets first header with given name, or returns default if header not present.
Gets first header with given name, or returns default if header not present.
- Inherited from
- HttpMessage
Gets first header value with given name.
Gets first header value with given name.
- Inherited from
- HttpMessage
Gets first header value with given name, or returns default if header not present.
Gets first header value with given name, or returns default if header not present.
- Inherited from
- HttpMessage
Creates message with supplied attributes.
Creates message with supplied attributes.
- Value Params
- more
additional attribute
- one
attribute
- Returns
new message
- Note
If attribute already exists, its value is replaced.
- Inherited from
- MessageBuilder
Creates message with supplied attribute.
Creates message with supplied attribute.
- Value Params
- attributes
attributes
- Returns
new message
- Note
If attribute already exists, its value is replaced.
- Inherited from
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
- Value Params
- more
additional headers
- one
header
- Returns
new message
- Note
All previous headers with same name are removed.
- Inherited from
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
- Value Params
- headers
message headers
- Returns
new message
- Note
All previous headers with same name are removed.
- Inherited from
- MessageBuilder
Creates message excluding attributes with given names.
Creates message excluding attributes with given names.
- Value Params
- more
additional attribute names
- one
attribute name
- Returns
new message
- Inherited from
- MessageBuilder
Creates message excluding attributes with given names.
Creates message excluding attributes with given names.
- Value Params
- names
attribute names
- Returns
new message
- Inherited from
- MessageBuilder
Creates message excluding headers with given names.
Creates message excluding headers with given names.
- Value Params
- more
additional header names
- one
header name
- Returns
new message
- Inherited from
- MessageBuilder
Creates message excluding headers with given names.
Creates message excluding headers with given names.
- Value Params
- names
header names
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied attributes.
Creates message with supplied attributes.
- Value Params
- more
additional message attributes
- one
message attribute
- Returns
new message
- Note
All previous attributes are removed.
- Inherited from
- MessageBuilder
Creates message with supplied attributes.
Creates message with supplied attributes.
- Value Params
- attributes
message attributes
- Returns
new message
- Note
All previous attributes are removed.
- Inherited from
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
- Value Params
- body
message body
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
- Value Params
- body
message body
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
- Value Params
- body
message body
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
- Value Params
- body
message body
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
- Value Params
- body
message body
- Returns
new message
- Inherited from
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
- Value Params
- more
additional message headers
- one
message header
- Returns
new message
- Note
All previous headers are removed.
- Inherited from
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
- Value Params
- headers
message headers
- Returns
new message
- Note
All previous headers are removed.
- Inherited from
- MessageBuilder
Creates message with supplied start line.
Creates message with supplied start line.
- Value Params
- startLine
message start line
- Returns
new message
- Inherited from
- MessageBuilder