scalaj.http

HttpRequest

case class HttpRequest(url: String, method: String, connectFunc: (HttpRequest, HttpURLConnection) ⇒ Unit, params: Seq[(String, String)], headers: Seq[(String, String)], options: Seq[(HttpURLConnection) ⇒ Unit], proxyConfig: Option[Proxy], charset: String, sendBufferSize: Int, urlBuilder: (HttpRequest) ⇒ String, compress: Boolean) extends Product with Serializable

Immutable builder for creating an http request

This is the workhorse of the scalaj-http library.

You shouldn't need to construct this manually. Use scalaj.http.Http.apply to get an instance

The params, headers and options methods are all additive. They will always add things to the request. If you want to replace those things completely, you can do something like

.copy(params=newparams)
Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. HttpRequest
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new HttpRequest(url: String, method: String, connectFunc: (HttpRequest, HttpURLConnection) ⇒ Unit, params: Seq[(String, String)], headers: Seq[(String, String)], options: Seq[(HttpURLConnection) ⇒ Unit], proxyConfig: Option[Proxy], charset: String, sendBufferSize: Int, urlBuilder: (HttpRequest) ⇒ String, compress: Boolean)

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def asBytes: HttpResponse[Array[Byte]]

    Execute this request and parse http body as Array[Byte]

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def asParamMap: HttpResponse[Map[String, String]]

    Execute this request and parse http body as query string key-value pairs

  9. def asParams: HttpResponse[Seq[(String, String)]]

    Execute this request and parse http body as query string key-value pairs

  10. def asString: HttpResponse[String]

    Execute this request and parse http body as String using configured charset

  11. def asToken: HttpResponse[Token]

    Execute this request and parse http body as a querystring containing oauth_token and oauth_token_secret tupple

  12. def auth(user: String, password: String): HttpRequest

    Add a standard basic authorization header

  13. def canEqual(arg0: Any): Boolean

    Definition Classes
    HttpRequest → Equals
  14. def charset(cs: String): HttpRequest

    Change the charset used to encode the request and decode the response.

    Change the charset used to encode the request and decode the response. UTF-8 by default

  15. val charset: String

  16. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  17. def compress(c: Boolean): HttpRequest

    Should HTTP compression be used If true, Accept-Encoding: gzip,deflate will be sent with request.

    Should HTTP compression be used If true, Accept-Encoding: gzip,deflate will be sent with request. If the server response with Content-Encoding: (gzip|deflate) the client will automatically handle decompression

    This is on by default

    c

    should compress

  18. val compress: Boolean

  19. val connectFunc: (HttpRequest, HttpURLConnection) ⇒ Unit

  20. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    HttpRequest → Equals → AnyRef → Any
  22. def exec[T](parser: (Int, Map[String, String], InputStream) ⇒ T): HttpResponse[T]

    Executes this request

    Executes this request

    This is a power user method for parsing the response body. The parser function will be passed the response code, response headers and the InputStream

    T

    the type returned by the input stream parser

    parser

    function to process the response body InputStream

  23. def execute[T](parser: (InputStream) ⇒ T): HttpResponse[T]

    Executes this request

    Executes this request

    T

    the type returned by the input stream parser

    parser

    function to process the response body InputStream. Will be used for all response codes

  24. def finalize(): Unit

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

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

    Definition Classes
    HttpRequest → AnyRef → Any
  27. def header(key: String, value: String): HttpRequest

    Add a http header to the request

  28. def headers(h: (String, String), rest: (String, String)*): HttpRequest

    Add http headers to the request

  29. def headers(h: Seq[(String, String)]): HttpRequest

    Add http headers to the request

  30. def headers(h: Map[String, String]): HttpRequest

    Add http headers to the request

  31. val headers: Seq[(String, String)]

  32. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  33. def method(m: String): HttpRequest

    Change the http request method.

    Change the http request method. The library will allow you to set this to whatever you want. If you want to do a POST, just use the postData, postForm, or postMulti methods. If you want to setup your request as a form, data or multi request, but want to change the method type, call this method after the post method:

    Http(url).postData(dataBytes).method("PUT").asString
    
  34. val method: String

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. final def notify(): Unit

    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  38. def oauth(consumer: Token, token: Option[Token], verifier: Option[String]): HttpRequest

    OAuth v1 sign the request with with both the consumer and client token and a verifier

  39. def oauth(consumer: Token, token: Token, verifier: String): HttpRequest

    OAuth v1 sign the request with with both the consumer and client token and a verifier

  40. def oauth(consumer: Token, token: Token): HttpRequest

    OAuth v1 sign the request with with both the consumer and client token

  41. def oauth(consumer: Token): HttpRequest

    OAuth v1 sign the request with the consumer token

  42. def option(o: (HttpURLConnection) ⇒ Unit): HttpRequest

    Entry point fo modifying the java.net.HttpURLConnection before the request is executed

  43. def options(o: (HttpURLConnection) ⇒ Unit, rest: (HttpURLConnection) ⇒ Unit*): HttpRequest

    Entry point fo modifying the java.net.HttpURLConnection before the request is executed

  44. def options(o: Seq[(HttpURLConnection) ⇒ Unit]): HttpRequest

    Entry point fo modifying the java.net.HttpURLConnection before the request is executed

  45. val options: Seq[(HttpURLConnection) ⇒ Unit]

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

    Add a param to the GET querystring or POST form request

  47. def params(p: (String, String), rest: (String, String)*): HttpRequest

    Add params to the GET querystring or POST form request

  48. def params(p: Seq[(String, String)]): HttpRequest

    Add params to the GET querystring or POST form request

  49. def params(p: Map[String, String]): HttpRequest

    Add params to the GET querystring or POST form request

  50. val params: Seq[(String, String)]

  51. def postData(data: Array[Byte]): HttpRequest

    Raw byte data POST request

  52. def postData(data: String): HttpRequest

    Raw data POST request.

    Raw data POST request. String bytes written out in using configured charset

  53. def postForm(params: Seq[(String, String)]): HttpRequest

    Standard form POST request and set some parameters.

    Standard form POST request and set some parameters. Same as .postForm.params(params)

  54. def postForm: HttpRequest

    Standard form POST request

  55. def postMulti(parts: MultiPart*): HttpRequest

    Multipart POST request.

    Multipart POST request.

    This is probably what you want if you need to upload a mix of form data and binary data (like a photo)

  56. def productArity: Int

    Definition Classes
    HttpRequest → Product
  57. def productElement(arg0: Int): Any

    Definition Classes
    HttpRequest → Product
  58. def productIterator: Iterator[Any]

    Definition Classes
    Product
  59. def productPrefix: String

    Definition Classes
    HttpRequest → Product
  60. def proxy(proxy: Proxy): HttpRequest

    Send request via a proxy

  61. def proxy(host: String, port: Int, proxyType: Type): HttpRequest

    Send request via a proxy.

    Send request via a proxy. You choose the type (HTTP or SOCKS)

  62. def proxy(host: String, port: Int): HttpRequest

    Send request via a standard http proxy

  63. val proxyConfig: Option[Proxy]

  64. def sendBufferSize(numBytes: Int): HttpRequest

    The buffer size to use when sending Multipart posts

  65. val sendBufferSize: Int

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

    Definition Classes
    AnyRef
  67. def timeout(connTimeoutMs: Int, readTimeoutMs: Int): HttpRequest

    The socket connection and read timeouts in milliseconds.

    The socket connection and read timeouts in milliseconds. Defaults are 1000 and 5000 respectively

  68. def toString(): String

    Definition Classes
    HttpRequest → AnyRef → Any
  69. val url: String

  70. val urlBuilder: (HttpRequest) ⇒ String

  71. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def productElements: Iterator[Any]

    Definition Classes
    Product
    Annotations
    @deprecated
    Deprecated

    (Since version 2.8.0) use productIterator instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any