scamper.http

package scamper.http

Members list

Type members

Classlikes

trait BodyDecoder

Provides access to decoded message body.

Provides access to decoded message body.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object BodyDecoder

Provides factory for BodyDecoder.

Provides factory for BodyDecoder.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
@FunctionalInterface
trait BodyParser[T]

Provides utility for parsing message body.

Provides utility for parsing message body.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object BodyParser

Provides factory for BodyParser.

Provides factory for BodyParser.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
BodyParser.type
@FunctionalInterface
trait BodyWriter

Defines body writer.

Defines body writer.

Attributes

Supertypes
class Object
trait Matchable
class Any
trait Entity

Provides input stream to HTTP entity.

Provides input stream to HTTP entity.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Entity

Provides factory for Entity.

Provides factory for Entity.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Entity.type
case class EntityTooLarge(maxLength: Long) extends IOException

Indicates entity larger than established maximum length.

Indicates entity larger than established maximum length.

EntityTooLarge is a complement to ReadLimitExceeded. Whereas ReadLimitExceeded applies to raw bytes of an input stream, EntityTooLarge applies to a constructed entity, which is potentially subject to decompression.

Attributes

See also
Supertypes
trait Product
trait Equals
class IOException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
sealed trait Header

Defines HTTP header.

Defines HTTP header.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Header

Provides factory for Header.

Provides factory for Header.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Header.type
case class HeaderNotFound(name: String) extends HttpException

Indicates absence of specified header.

Indicates absence of specified header.

Attributes

Supertypes
trait Product
trait Equals
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
class HttpException(message: String, cause: Throwable) extends RuntimeException

Indicates exception in HTTP processing.

Indicates exception in HTTP processing.

Value parameters

cause

underlying cause

message

detail message

Attributes

Constructor

Constructs HttpException with supplied detail message and cause.

Supertypes
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed trait HttpMessage

Defines HTTP message.

Defines HTTP message.

HttpMessage defines fundamental characteristics of an HTTP message. HttpRequest and HttpResponse extend the specification to define characteristics specific to their respective message types.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Defines HTTP request.

Defines HTTP request.

A request is created using one of its factory methods, or you can start with a RequestMethod and build from there.

import scala.language.implicitConversions

import scamper.http.{ BodyParser, Header, stringToUri }
import scamper.http.RequestMethod.Registry.Get

val request = Get("/motd").setHeaders(
 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")

given BodyParser[String] = BodyParser.string()

printf("Body: %s%n", request.as[String])

Attributes

See also
Companion
object
Supertypes
trait HttpMessage
class Object
trait Matchable
class Any
object HttpRequest

Provides factory for HttpRequest.

Provides factory for HttpRequest.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Defines HTTP response.

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
Supertypes
trait HttpMessage
class Object
trait Matchable
class Any
object HttpResponse

Provides factory for HttpResponse.

Provides factory for HttpResponse.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait HttpVersion

Defines HTTP version.

Defines HTTP version.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object HttpVersion

Provides factory for HttpVersion.

Provides factory for HttpVersion.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Provides builder pattern for HTTP message.

Provides builder pattern for HTTP message.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
T
trait QueryString

Represents query string as mapped parameters.

Represents query string as mapped parameters.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object QueryString

Provides factory for QueryString.

Provides factory for QueryString.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case class ReadLimitExceeded(limit: Long) extends IOException

Indicates read of input stream exceeds established limit.

Indicates read of input stream exceeds established limit.

ReadLimitExceeded is a complement to EntityTooLarge. Whereas ReadLimitExceeded applies to raw bytes of an input stream, EntityTooLarge applies to a constructed entity, which is potentially subject to decompression.

Attributes

See also
Supertypes
trait Product
trait Equals
class IOException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
sealed trait RequestLine extends StartLine

Defines HTTP request line.

Defines HTTP request line.

Attributes

See also
Companion
object
Supertypes
trait StartLine
class Object
trait Matchable
class Any
object RequestLine

Provides factory for RequestLine.

Provides factory for RequestLine.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait RequestMethod

Defines HTTP request method.

Defines HTTP request method.

Attributes

See also
Companion
object
Supertypes
class Object
trait Matchable
class Any
object RequestMethod

Provides factory for RequestMethod.

Provides factory for RequestMethod.

Attributes

See also
Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ResponseStatus

Defines HTTP response status.

Defines HTTP response status.

Attributes

See also
Companion
object
Supertypes
class Object
trait Matchable
class Any

Provides factory for ResponseStatus.

Provides factory for ResponseStatus.

Attributes

See also
Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait StartLine

Defines HTTP message start line.

Defines HTTP message start line.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait RequestLine
trait StatusLine
sealed trait StatusLine extends StartLine

Defines HTTP status line.

Defines HTTP status line.

Attributes

See also
Companion
object
Supertypes
trait StartLine
class Object
trait Matchable
class Any
object StatusLine

Provides factory for StatusLine.

Provides factory for StatusLine.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
StatusLine.type
sealed trait Uri

Defines URI.

Defines URI.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Uri

Provides factory for Uri.

Provides factory for Uri.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Uri.type
class UriBuilder(uri: Uri)

Defines URI builder.

Defines URI builder.

Attributes

Constructor

Creates builder initialized to supplied URI.

Supertypes
class Object
trait Matchable
class Any

Givens

Givens

given bodyWriterToEntity: Conversion[BodyWriter, Entity]

Converts body writer to Entity.

Converts body writer to Entity.

Attributes

given bytesToEntity: Conversion[Array[Byte], Entity]

Converts byte array to Entity.

Converts byte array to Entity.

Attributes

given fileToEntity: Conversion[File, Entity]

Converts file to Entity.

Converts file to Entity.

Attributes

given inputStreamToEntity: Conversion[InputStream, Entity]

Converts input stream to Entity.

Converts input stream to Entity.

Attributes

given intToResponseStatus: Conversion[Int, ResponseStatus]

Converts int to ResponseStatus.

Converts int to ResponseStatus.

Attributes

given stringToEntity: Conversion[String, Entity]

Converts string to Entity.

Converts string to Entity.

Attributes

given stringToHeader: Conversion[String, Header]

Converts string to Header.

Converts string to Header.

Attributes

given stringToRequestMethod: Conversion[String, RequestMethod]

Converts string to RequestMethod.

Converts string to RequestMethod.

Attributes

given stringToUri: Conversion[String, Uri]

Converts string to Uri.

Converts string to Uri.

Attributes

given tupleToHeader: Conversion[(String, String), Header]

Converts tuple to Header where tuple is name-value pair.

Converts tuple to Header where tuple is name-value pair.

Attributes

given tupleToHeaderWithInstantValue: Conversion[(String, Instant), Header]

Converts tuple to Header where tuple is name-value pair.

Converts tuple to Header where tuple is name-value pair.

Attributes

given tupleToHeaderWithIntValue: Conversion[(String, Int), Header]

Converts tuple to Header where tuple is name-value pair.

Converts tuple to Header where tuple is name-value pair.

Attributes

given tupleToHeaderWithLongValue: Conversion[(String, Long), Header]

Converts tuple to Header where tuple is name-value pair.

Converts tuple to Header where tuple is name-value pair.

Attributes

Extensions

Extensions

extension (headers: Seq[Header])
def getHeader(name: String): Option[Header]

Gets first header with given name.

Gets first header with given name.

Attributes

def getHeaderOrElse(name: String, default: => Header): Header

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

def getHeaderValue(name: String): Option[String]

Gets first header value with given name.

Gets first header value with given name.

Attributes

def getHeaderValueOrElse(name: String, default: => String): String

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

def getHeaderValues(name: String): Seq[String]

Gets header values with given name.

Gets header values with given name.

Attributes

def getHeaders(name: String): Seq[Header]

Gets headers with given name.

Gets headers with given name.

Attributes

def hasHeader(name: String): Boolean

Tests for header with given name.

Tests for header with given name.

Attributes

extension [T <: HttpMessage & MessageBuilder[LazyRef(...)]](message: T)
def setFileBody(file: File): T

Creates new message with supplied file as message body.

Creates new message with supplied file as message body.

Content-Type is set according to file name, and Content-Length is set to length of file.

Value parameters

file

message body

Attributes

See also
def setFormBody(query: QueryString): T

Creates new message with supplied query string as message body.

Creates new message with supplied query string as message body.

Content-Type is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded form data.

Value parameters

query

message body

Attributes

def setFormBody(data: (String, String), more: (String, String)*): T

Creates new message with supplied form data as message body.

Creates new message with supplied form data as message body.

Content-Type is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded form data.

Value parameters

data

form data

more

additional form data

Attributes

def setOctetBody(bytes: Array[Byte]): T

Creates new message with supplied bytes as message body.

Creates new message with supplied bytes as message body.

Content-Type is set to application/octet-stream; Content-Length is set to length of bytes.

Value parameters

bytes

message body

charset

character set

Attributes

def setPlainBody(text: String, charset: String): T

Creates new message with supplied text as message body.

Creates new message with supplied text as message body.

Content-Type is set to text/plain with specified charset, and Content-Length is set to length of encoded text.

Value parameters

charset

character set

text

message body

Attributes