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])
Attributes
- See also
- Companion
- object
- Graph
-
- Supertypes
Members list
Type members
Types
Specifies start line type.
Specifies start line type.
Attributes
Value members
Concrete methods
Tests for client error status.
Tests for client error status.
Attributes
Tests for informational status.
Tests for informational status.
Attributes
Tests for redirection status.
Tests for redirection status.
Attributes
Tests for server error status.
Tests for server error status.
Attributes
Tests for successful status.
Tests for successful status.
Attributes
Gets reason phrase.
Gets reason phrase.
Attributes
Creates response with new status.
Creates response with new status.
Attributes
- Returns
-
new response
Creates response with new HTTP version.
Creates response with new HTTP version.
Attributes
- Returns
-
new response
Gets response status.
Gets response status.
Attributes
Gets status code.
Gets status code.
Attributes
Inherited methods
Creates message with additional headers.
Creates message with additional headers.
Value parameters
- more
-
additional message headers
- one
-
message header
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with additional headers.
Creates message with additional headers.
Value parameters
- headers
-
message headers
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Gets message body as instance of T
.
Gets message body as instance of T
.
Value parameters
- parser
-
body parser
Attributes
- Inherited from:
- HttpMessage
Gets message attributes.
Gets message attributes.
Attributes
- Note
-
Attributes are arbitrary values associated with message and are not part of transmitted message.
- Inherited from:
- HttpMessage
Gets message body.
Drains decoded message body to supplied sink.
Drains decoded message body to supplied sink.
Value parameters
- maxLength
-
maximum number of bytes
- sink
-
sink to which message body is written
Attributes
- Returns
-
number of bytes written
- Throws
-
ReadLimitExceeded
if body exceeds
maxLength
- Inherited from:
- HttpMessage
Drains decoded message body.
Drains decoded message body.
Value parameters
- maxLength
-
maximum number of bytes
Attributes
- Returns
-
this message
- Throws
-
ReadLimitExceeded
if body exceeds
maxLength
- Inherited from:
- HttpMessage
Gets attribute value with given name.
Gets attribute value with given name.
Value parameters
- name
-
attribute name
Attributes
- 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 parameters
- default
-
default value
- name
-
attribute name
Attributes
- Inherited from:
- HttpMessage
Gets first header with given name.
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.
Attributes
- Inherited from:
- HttpMessage
Gets first header value with given name.
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.
Attributes
- Inherited from:
- HttpMessage
Gets header values with given name.
Gets headers with given name.
Tests for header with given name.
Gets message headers.
Creates message with supplied attributes.
Creates message with supplied attributes.
Value parameters
- more
-
additional attribute
- one
-
attribute
Attributes
- 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 parameters
- attributes
-
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 parameters
- more
-
additional headers
- one
-
header
Attributes
- 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 parameters
- headers
-
message headers
Attributes
- 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 parameters
- more
-
additional attribute names
- one
-
attribute name
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message excluding attributes with given names.
Creates message excluding attributes with given names.
Value parameters
- names
-
attribute names
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message excluding headers with given names.
Creates message excluding headers with given names.
Value parameters
- more
-
additional header names
- one
-
header name
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message excluding headers with given names.
Creates message excluding headers with given names.
Value parameters
- names
-
header names
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with supplied attributes.
Creates message with supplied attributes.
Value parameters
- more
-
additional message attributes
- one
-
message attribute
Attributes
- Returns
-
new message
- Note
-
All previous attributes are removed.
- Inherited from:
- MessageBuilder
Creates message with supplied attributes.
Creates message with supplied attributes.
Value parameters
- attributes
-
message attributes
Attributes
- Returns
-
new message
- Note
-
All previous attributes are removed.
- Inherited from:
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
Value parameters
- body
-
message body
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
Value parameters
- body
-
message body
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
Value parameters
- body
-
message body
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with supplied body.
Creates message with supplied body.
Value parameters
- body
-
message body
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
Value parameters
- more
-
additional message headers
- one
-
message header
Attributes
- Returns
-
new message
- Note
-
All previous headers are removed.
- Inherited from:
- MessageBuilder
Creates message with supplied headers.
Creates message with supplied headers.
Value parameters
- headers
-
message headers
Attributes
- 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 parameters
- startLine
-
message start line
Attributes
- Returns
-
new message
- Inherited from:
- MessageBuilder
Gets message start line.
Gets HTTP version.