Class/Object

fr.hmil.roshttp

HttpRequest

Related Docs: object HttpRequest | package roshttp

Permalink

final class HttpRequest extends AnyRef

Builds an HTTP request.

The request is sent using send. A request can be sent multiple times. Each time yields a Future[HttpResponse] which either succeeds with an HttpResponse or fails with an HttpNetworkError or HttpResponseError

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. HttpRequest
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val body: Option[BodyPart]

    Permalink
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. val headers: HeaderMap[String]

    Permalink
  13. val host: String

    Permalink
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. val longPath: String

    Permalink

    The path with the query string or just the path if there is no query string

  16. val method: Method

    Permalink
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. def options(body: BodyPart): Future[HttpResponse]

    Permalink

    Sends this request with the OPTIONS method and a body

    Sends this request with the OPTIONS method and a body

    body

    The body to send with the request

    returns

    A future of HttpResponse which may fail with an HttpNetworkError or HttpResponseError

    See also

    post

  21. val path: String

    Permalink
  22. val port: Option[Int]

    Permalink
  23. def post(body: BodyPart): Future[HttpResponse]

    Permalink

    Sends this request with the POST method and a body

    Sends this request with the POST method and a body

    body

    The body to send with the request

    returns

    A future of HttpResponse which may fail with an HttpNetworkError or HttpResponseError

    See also

    send

  24. val protocol: Protocol

    Permalink
  25. def put(body: BodyPart): Future[HttpResponse]

    Permalink

    Sends this request with the PUT method and a body

    Sends this request with the PUT method and a body

    body

    The body to send with the request

    returns

    A future of HttpResponse which may fail with an HttpNetworkError or HttpResponseError

    See also

    post

  26. val queryString: Option[String]

    Permalink
  27. def send(body: BodyPart): Future[HttpResponse]

    Permalink

    Sends this request with a body.

    Sends this request with a body.

    This method should not be used directly. If you want to post or put some data, you should use the appropriate methods. If you do not want to send data with the request, you should use post without arguments.

    body

    The body to send.

    returns

    A future of HttpResponse which may fail with an HttpNetworkError or HttpResponseError

  28. def send(): Future[HttpResponse]

    Permalink

    Sends this request.

    Sends this request.

    A request can be sent multiple times. When a request is sent, it returns a Future[HttpResponse] which either succeeds with an HttpResponse or fails.

    Possible reasons for the future failing are: - A status code >= 400 (HttpResponseError) - A network error (HttpNetworkError)

    returns

    A future of HttpResponse which may fail with an HttpNetworkError or HttpResponseError

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  30. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  31. val url: String

    Permalink

    The target url for this request

  32. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. def withBody(body: BodyPart): HttpRequest

    Permalink

    Attaches a body to this request and sets the Content-Type header.

    Attaches a body to this request and sets the Content-Type header.

    The body will be sent with the request regardless of other parameters once send() is invoked. Any subsequent call to withBody(), send(BodyPart), post(BodyPart), put(BodyPart) or similar methods will override the request body.

    The Content-Type header is set to this body's content-type. It can still be manually overridden using a method of the withHeader() family.

    Note that the HTTP spec forbids sending data with some methods. In case you need to deal with a broken backend, this library allows you to do so anyway. **Beware that in this case, the JVM can still enforce a compliant HTTP method**.

  36. def withDefaultPort(): HttpRequest

    Permalink

    Discards changes introduced by any call to withPort

    Discards changes introduced by any call to withPort

    returns

    A copy of this HttpRequest with no explicit port.

  37. def withHeader(key: String, value: String): HttpRequest

    Permalink

    Adds or updates a header to the current set of headers.

    Adds or updates a header to the current set of headers.

    key

    The header key (case insensitive)

    value

    The header value

    returns

    A copy of this HttpRequest with an updated header set.

  38. def withHeaders(newHeaders: (String, String)*): HttpRequest

    Permalink

    Adds or updates multiple headers to the current set of headers.

    Adds or updates multiple headers to the current set of headers.

    newHeaders

    The headers to add.

    returns

    A copy of this HttpRequest with an updated header set.

  39. def withHost(host: String): HttpRequest

    Permalink

    Sets the host used in the request URI.

    Sets the host used in the request URI.

    host

    The new host

    returns

    A copy of this HttpRequest with an updated host

  40. def withMethod(method: Method): HttpRequest

    Permalink

    Sets the HTTP method.

    Sets the HTTP method. Defaults to GET.

    Beware of browser limitations when using exotic methods.

    method

    The new method

    returns

    A copy of this HttpRequest with an updated method

  41. def withPath(path: String): HttpRequest

    Permalink

    Sets the path used in the request URI.

    Sets the path used in the request URI.

    The path is the part that lies between the host (or port if present) and the query string or the end of the request. Note that the query string is not part of the path.

    path

    The new path, including the leading '/' and excluding any '?' or '#' and subsequent characters

    returns

    A copy of this HttpRequest with an updated path

  42. def withPort(port: Int): HttpRequest

    Permalink

    Sets the port used in the request URI.

    Sets the port used in the request URI.

    port

    The new port

    returns

    A copy of this HttpRequest with an updated port

  43. def withProtocol(protocol: Protocol): HttpRequest

    Permalink

    Sets the protocol used in the request URL.

    Sets the protocol used in the request URL.

    Setting the protocol also sets the port accordingly (80 for HTTP, 443 for HTTPS).

    protocol

    The HTTP or HTTPS protocol

    returns

    A copy of this HttpRequest with an updated protocol and port

  44. def withQueryArrayParameter(key: String, values: Seq[String]): HttpRequest

    Permalink

    Adds a query array parameter.

    Adds a query array parameter.

    Although this is not part of a spec, most servers recognize bracket indices in a query string as array indices or object keys.

    example: ?list[0]=foo&list[1]=bar

    This method formats array values according to the above example.

    key

    The unescaped parameter key

    values

    The unescaped parameter array values

    returns

    A copy of this HttpRequest with an updated query string.

    See also

    withQueryArrayParameter(String,String)

  45. def withQueryObjectParameter(key: String, values: Seq[(String, String)]): HttpRequest

    Permalink

    Adds a query map parameter.

    Adds a query map parameter.

    Although this is not part of a spec, most servers recognize bracket indices in a query string as array indices or object keys.

    example: ?obj[foo]=bar&obj[baz]=42

    This method formats map values according to the above example.

    key

    The unescaped parameter key

    values

    The unescaped parameter map values

    returns

    A copy of this HttpRequest with an updated query string.

    See also

    withQueryArrayParameter(String,String)

  46. def withQueryParameter(key: String, value: String): HttpRequest

    Permalink

    Adds a query parameter key/value pair.

    Adds a query parameter key/value pair.

    Query parameters end up in the query string as key=value pairs separated by ampersands. Both the key and parameter are escaped to ensure proper query string format.

    key

    The unescaped parameter key

    value

    The unescaped parameter value

    returns

    A copy of this HttpRequest with an updated query string.

  47. def withQueryParameters(parameters: (String, String)*): HttpRequest

    Permalink

    Adds multiple query parameters.

    Adds multiple query parameters.

    parameters

    A sequence of new, unescaped parameters.

    returns

    A copy of this HttpRequest with an updated query string.

    See also

    withQueryArrayParameter(String,String)

  48. def withQueryString(queryString: String): HttpRequest

    Permalink

    Sets the query string.

    Sets the query string.

    The argument is escaped by this method. If you want to bypass the escaping, use withQueryStringRaw.

    Escaping also means that the queryString property will generally not be equal to what you passed as argument to withQueryString.

    For instance: request.withQueryString("äéuô").queryString.get != "%C3%A4%C3%A9u%C3%B4"

    queryString

    The unescaped query string.

    returns

    A copy of this HttpRequest with an updated queryString

  49. def withQueryStringRaw(queryString: String): HttpRequest

    Permalink

    Sets the query string without escaping.

    Sets the query string without escaping.

    Raw query strings must only contain legal characters as per rfc3986. Adding special characters yields undefined behaviour.

    In most cases, withQueryString should be preferred.

    queryString

    The raw, escaped query string

    returns

    A copy of this HttpRequest with an updated queryString

  50. def withURL(url: String): HttpRequest

    Permalink

    Updates request protocol, host, port, path and queryString according to a url.

    Updates request protocol, host, port, path and queryString according to a url.

    url

    A valid HTTP url

    returns

    A copy of this HttpRequest with updated URL-related attributes.

  51. def withoutQueryString(): HttpRequest

    Permalink

    Removes the query string.

    Removes the query string.

    returns

    A copy of this HttpRequest without query string

Inherited from AnyRef

Inherited from Any

Ungrouped