Packages

  • package root

    Provided herein is API documentation for Scamper, the HTTP library for Scala.

    Provided herein is API documentation for Scamper, the HTTP library for Scala.

    Definition Classes
    root
  • package scamper

    Defines core types.

    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").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")

    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.").setHeaders(
      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])
    Definition Classes
    root
  • object ResponseStatus

    Provides factory for ResponseStatus.

    Provides factory for ResponseStatus.

    Definition Classes
    scamper
    See also

    ResponseStatus.Registry

  • Registry

object Registry

Contains registered response statuses.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Registry
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val Accepted: ResponseStatus

    202 Accepted

  5. val BadGateway: ResponseStatus

    502 Bad Gateway

  6. val BadRequest: ResponseStatus

    400 Bad Request

  7. val Conflict: ResponseStatus

    409 Conflict

  8. val Continue: ResponseStatus

    100 Continue

  9. val Created: ResponseStatus

    201 Created

  10. val EarlyHints: ResponseStatus

    103 Early Hints

  11. val ExpectationFailed: ResponseStatus

    417 Expectation Failed

  12. val Forbidden: ResponseStatus

    403 Forbidden

  13. val Found: ResponseStatus

    302 Found

  14. val GatewayTimeout: ResponseStatus

    504 Gateway Timeout

  15. val Gone: ResponseStatus

    410 Gone

  16. val HttpVersionNotSupported: ResponseStatus

    505 HTTP Version Not Supported

  17. val InternalServerError: ResponseStatus

    500 Internal Server Error

  18. val LengthRequired: ResponseStatus

    411 Length Required

  19. val MethodNotAllowed: ResponseStatus

    405 Method Not Allowed

  20. val MovedPermanently: ResponseStatus

    301 Moved Permanently

  21. val MultipleChoices: ResponseStatus

    300 Multiple Choices

  22. val NetworkAuthenticationRequired: ResponseStatus

    511 Network Authentication Required

  23. val NoContent: ResponseStatus

    204 No Content

  24. val NonAuthoritativeInformation: ResponseStatus

    203 Non-Authoritative Information

  25. val NotAcceptable: ResponseStatus

    406 Not Acceptable

  26. val NotFound: ResponseStatus

    404 Not Found

  27. val NotImplemented: ResponseStatus

    501 Not Implemented

  28. val NotModified: ResponseStatus

    304 Not Modified

  29. val Ok: ResponseStatus

    200 OK

  30. val PartialContent: ResponseStatus

    206 Partial Content

  31. val PayloadTooLarge: ResponseStatus

    413 Payload Too Large

  32. val PaymentRequired: ResponseStatus

    402 Payment Required

  33. val PermanentRedirect: ResponseStatus

    308 Permanent Redirect

  34. val PreconditionFailed: ResponseStatus

    412 Precondition Failed

  35. val PreconditionRequired: ResponseStatus

    428 Precondition Required

  36. val ProxyAuthenticationRequired: ResponseStatus

    407 Proxy Authentication Required

  37. val RangeNotSatisfiable: ResponseStatus

    416 Range Not Satisfiable

  38. val RequestHeaderFieldsTooLarge: ResponseStatus

    431 Request Header Fields Too Large

  39. val RequestTimeout: ResponseStatus

    408 Request Timeout

  40. val ResetContent: ResponseStatus

    205 Reset Content

  41. val SeeOther: ResponseStatus

    303 See Other

  42. val ServiceUnavailable: ResponseStatus

    503 Service Unavailable

  43. val SwitchingProtocols: ResponseStatus

    101 Switching Protocols

  44. val TemporaryRedirect: ResponseStatus

    307 Temporary Redirect

  45. val TooEarly: ResponseStatus

    425 Too Early

  46. val TooManyRequests: ResponseStatus

    429 Too Many Requests

  47. val Unauthorized: ResponseStatus

    401 Unauthorized

  48. val UnavailableForLegalReasons: ResponseStatus

    451 Unavailable For Legal Reasons

  49. val UnprocessableEntity: ResponseStatus

    422 Unprocessable Entity

  50. val UnsupportedMediaType: ResponseStatus

    415 Unsupported Media Type

  51. val UpgradeRequired: ResponseStatus

    426 Upgrade Required

  52. val UriTooLong: ResponseStatus

    414 URI Too Long

  53. val UseProxy: ResponseStatus

    305 Use Proxy

  54. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  55. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  56. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  57. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  58. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  59. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  60. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  61. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  62. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  63. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  64. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  65. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  66. def toString(): String
    Definition Classes
    AnyRef → Any
  67. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  69. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped