scamper
package scamper
Defines core types.
HTTP Messages
At the core of 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 a factory method 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.RequestMethod.Registry.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 a factory method defined in its companion object. Or you can start with a ResponseStatus and use builder methods to further define the response.
import scamper.{ BodyParser, Header } import scamper.Implicits.stringToEntity import scamper.ResponseStatus.Registry.Ok val response = Ok("There is an answer.").withHeaders( Header("Content-Type: text/plain"), Header("Connection: close") ) printf("Status Code: %s%n", response.statusCode) printf("Reason Phrase: %s%n", response.reasonPhrase) response.headers.foreach(println) val contentType: Option[String] = response.getHeaderValue("Content-Type") implicit val parser = BodyParser.text() printf("Body: %s%n", response.as[String])
- Alphabetic
- By Inheritance
- scamper
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
BodyDecoder extends AnyRef
Provides access to decoded message body.
-
trait
BodyParser[T] extends AnyRef
Provides utility for parsing message body.
-
trait
Entity extends AnyRef
Provides input stream to HTTP entity.
-
case class
EntityTooLarge(maxLength: Long) extends IOException with Product with Serializable
Indicates entity larger than established maximum length.
Indicates entity larger than established maximum length.
EntityTooLarge
is a complement toReadLimitExceeded
. WhereasReadLimitExceeded
applies to raw bytes of an input stream,EntityTooLarge
applies to a constructed entity, which is potentially subject 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
Defines 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.
-
sealed
trait
HttpMessage extends AnyRef
Defines HTTP message.
-
trait
HttpRequest extends HttpMessage with MessageBuilder[HttpRequest]
Defines HTTP request.
Defines HTTP request.
- See also
-
trait
HttpResponse extends HttpMessage with MessageBuilder[HttpResponse]
Defines HTTP response.
Defines HTTP response.
- See also
-
trait
HttpVersion extends AnyRef
Defines 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
-
sealed
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 read of input stream exceeds established limit.
Indicates read of input stream exceeds established limit.
ReadLimitExceeded
is a complement toEntityTooLarge
. WhereasReadLimitExceeded
applies to raw bytes of an input stream,EntityTooLarge
applies to a constructed entity, which is potentially subject to decompression.- See also
-
trait
RequestLine extends StartLine
Defines HTTP request line.
Defines HTTP request line.
- See also
-
trait
RequestMethod extends AnyRef
Defines HTTP request method.
Defines HTTP request method.
- See also
-
trait
ResponseStatus extends AnyRef
Defines HTTP response status.
Defines HTTP response status.
- See also
-
sealed
trait
StartLine extends AnyRef
Defines HTTP message start line.
-
trait
StatusLine extends StartLine
Defines HTTP status line.
Defines 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
-
type
Uri = URI
Uniform Resource Identifier
Value Members
-
object
BodyDecoder
Provides factory for
BodyDecoder
. -
object
BodyParser
Provides factory for
BodyParser
. -
object
Entity
Provides factory for
Entity
. -
object
FilePart
Provides factory for
FilePart
. -
object
Header
Provides factory for
Header
. -
object
HttpRequest
Provides factory for
HttpRequest
. -
object
HttpResponse
Provides factory for
HttpResponse
. -
object
HttpVersion
Provides factory for
HttpVersion
. -
object
Implicits
Includes implicit converter functions and type classes.
-
object
Multipart
Provides factory for
Multipart
. -
object
QueryString
Provides factory for
QueryString
. -
object
RequestLine
Provides factory for
RequestLine
. -
object
RequestMethod
Provides factory for
RequestMethod
.Provides factory for
RequestMethod
.- See also
-
object
ResponseStatus
Provides factory for
ResponseStatus
.Provides factory for
ResponseStatus
.- See also
-
object
StatusLine
Provides factory for
StatusLine
. -
object
TextPart
Provides factory for
TextPart
. -
object
Uri
Provides factory for
Uri
.
Provided herein is API documentation for Scamper, the HTTP library for Scala.