scamper
package scamper
The HTTP library for Scala.
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 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.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 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.{ 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.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 = BodyParser.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
Provides access to decoded message body.
-
trait
BodyParser[T] extends AnyRef
Provides utility for parsing HTTP message body.
-
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
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 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
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
BodyDecoding
Provides factory methods for
BodyDecoding
. -
object
BodyParser
Provides factory methods for
BodyParser
. -
object
Entity
Provides factory methods for
Entity
. -
object
FilePart
Provides factory methods for
FilePart
. -
object
Header
Provides factory methods for
Header
. -
object
HttpRequest
Provides factory methods for
HttpRequest
. -
object
HttpResponse
Provides factory methods for
HttpResponse
. -
object
HttpVersion
Provides factory methods for
HttpVersion
. -
object
Implicits
Includes implicit converter functions.
-
object
Multipart
Provides factory methods for
Multipart
. -
object
QueryString
Provides factory methods for
QueryString
. -
object
RequestLine
Provides factory methods for
RequestLine
. -
object
RequestMethod
Provided factory methods for
RequestMethod
.Provided factory methods for
RequestMethod
.- See also
-
object
ResponseStatus
Provides factory methods for
ResponseStatus
.Provides factory methods for
ResponseStatus
.- See also
-
object
StatusLine
Provides factory methods for
StatusLine
. -
object
TextPart
Provides factory methods for
TextPart
. -
object
Uri
Provides factory methods for
Uri
.