scamper
package scamper
HTTP Messages
At the core Scamper is HttpMessage, which is a trait that defines the fundamental characteristics of an HTTP message. HttpRequest and HttpResponse extend the specification to define characteristics specific to their respective message types.
An HttpRequest is created using one of the factory methods defined in its companion object. Or you can start with a RequestMethod and use builder methods to further define the request.
import scamper.Header import scamper.Implicits.stringToUri import scamper.RequestMethods.GET val request = GET("/motd").withHeaders( Header("Host", "localhost:8080"), Header("Accept", "text/plain") ) printf("Request Method: %s%n", request.method) printf("Target URI: %s%n", request.target) request.headers.foreach(println) val host: Option[String] = request.getHeaderValue("Host")
An HttpResponse is created using one of the factory methods defined in its companion object. Or you can start with a ResponseStatus and use builder methods to further define the response.
import scamper.{ BodyParsers, Header } import scamper.Implicits.stringToEntity import scamper.ResponseStatuses.Ok val response = Ok("There is an answer.").withHeaders( Header("Content-Type", "text/plain"), Header("Connection", "close") ) printf("Status Code: %s%n", response.status.code) printf("Reason Phrase: %s%n", response.status.reason) response.headers.foreach(println) val contentType: Option[String] = response.getHeaderValue("Content-Type") implicit val parser = BodyParsers.text() printf("Body: %s%n", response.as[String])
- Alphabetic
- By Inheritance
- scamper
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
BodyDecoding extends AnyRef
A mixin providing access to decoded message body.
-
trait
BodyParser[T] extends AnyRef
Provides utility for parsing HTTP message body.
Provides utility for parsing HTTP message body.
- See also
-
trait
Entity extends AnyRef
Representation of message body.
-
case class
EntityTooLarge(limit: Long) extends HttpException with Product with Serializable
Indicates entity exceeds established limit.
Indicates entity exceeds established limit.
EntityTooLarge
is a complement toReadLimitExceeded
. WhereasReadLimitExceeded
applies to the raw bytes of an input stream,EntityTooLarge
pertains to the entity itself, potentially subjected to decompression.- See also
-
trait
FilePart extends Part
Represents file content in multipart form data.
Represents file content in multipart form data.
- See also
-
trait
Header extends AnyRef
HTTP header
-
case class
HeaderNotFound(name: String) extends HttpException with Product with Serializable
Indicates absence of specified header.
-
class
HttpException extends RuntimeException
Indicates exception in HTTP processing.
-
trait
HttpMessage extends AnyRef
HTTP message
-
trait
HttpRequest extends HttpMessage with MessageBuilder[HttpRequest]
HTTP request
HTTP request
- See also
-
trait
HttpResponse extends HttpMessage with MessageBuilder[HttpResponse]
HTTP response
HTTP response
- See also
-
trait
HttpVersion extends AnyRef
HTTP version
-
trait
MessageBuilder[T <: HttpMessage] extends AnyRef
Provides builder pattern for HTTP message.
-
trait
Multipart extends AnyRef
Represents multipart form data.
Represents multipart form data.
- See also
-
trait
Part extends AnyRef
Represents part in multipart form data.
Represents part in multipart form data.
- See also
-
trait
QueryString extends AnyRef
Represents query string as mapped parameters.
-
case class
ReadLimitExceeded(limit: Long) extends IOException with Product with Serializable
Indicates attempt to read beyond an
InputStream
's established limit.Indicates attempt to read beyond an
InputStream
's established limit.ReadLimitExceeded
is a complement toEntityTooLarge
. WhereasReadLimitExceeded
applies to the raw bytes of an input stream,EntityTooLarge
pertains to the entity itself, potentially subjected to decompression.- See also
-
trait
RequestLine extends StartLine
HTTP request line
HTTP request line
- See also
-
trait
RequestMethod extends AnyRef
HTTP request method
HTTP request method
- See also
-
trait
ResponseStatus extends AnyRef
HTTP response status
HTTP response status
- See also
-
trait
StartLine extends AnyRef
HTTP message start line
-
trait
StatusLine extends StartLine
HTTP status line
HTTP status line
- See also
-
trait
TextPart extends Part
Represents text content in multipart form data.
Represents text content in multipart form data.
- See also
Value Members
-
object
BodyParsers
Includes default body parser implementations.
-
object
Entity
Provides factory for
Entity
. -
object
FilePart
Provides factory for FilePart.
-
object
Header
Provided for factory for
Header
. -
object
HttpRequest
HttpRequest factory
-
object
HttpResponse
HttpResponse factory
-
object
HttpVersion
HttpVersion factory
-
object
Implicits
Includes implicit converter functions.
-
object
Multipart
Provides factory for Multipart.
-
object
QueryString
Provides factory methods for QueryString.
-
object
RequestLine
RequestLine factory
-
object
RequestMethod
Provided factory for
RequestMethod
.Provided factory for
RequestMethod
.- See also
-
object
RequestMethods
Includes registered request methods.
-
object
ResponseStatus
Provided factory for
ResponseStatus
.Provided factory for
ResponseStatus
.- See also
-
object
ResponseStatuses
Includes standard HTTP statuses.
-
object
StatusLine
StatusLine factory
-
object
TextPart
Provides factory for TextPart.