Skip to content

Latest commit

 

History

History
70 lines (48 loc) · 2.34 KB

0.9.1.markdown

File metadata and controls

70 lines (48 loc) · 2.34 KB

API Changes

The / path builder now url-encodes provided paths.

val r = host("example.com") / "génial"

This means that any single path element may be appended without concern, bit it also necessarily renders the path builder incompatible with partially constructed paths.

val r = host("example.com") / "no/bad"

Since all characters are encoded to create a single path element, the encoded slash will not function as a path divider. If you are constructing paths outside of Dispatch, it's better not to use the path builder. Construct the URL according to your own specifications, and pass it into the url builder.

val r = url("http://example.com/%s".format("okay/fine"))

Promise executor

In this Dispatch version the configured AsyncHttpClient executor is no longer used for Promise compositions, as it defaults to a cached thread pool of unbounded size.

Instead, promises will default to a fixed thread pool executor of size 256 . Applications that contain no blocking I/O may configure a smaller pool for less overhead.

val http = Http.threads(16)

Applications that do perform blocking I/O may wish to configure a larger pool than the default.

Exception handling

A new method Promise#fold can facilitate error handling. Given functions a and b which respectively handle Throwable and the return type of the response handler, these are equivalent:

myPromise.either.map { _.fold(a, b) }

myPromise.fold(a, b)

This makes it easier to handle both connection exceptions and unexpected response statuses at the outset of response handling.

Additions

  • Scala 2.10.0-M7 artifact for the core module
  • JSoup integration module for HTML parsing
  • Added TRACE and OPTIONS HTTP request methods issue 11
  • PUT request verb <<<
  • POST request verb << now supports String request bodies
  • Added <:< request header verb for appending a scala collection of header names and values issue 10

Below is an example of sending a key header with a value of value to host

import dispatch._
Http(url(host) <:< Map(key <- value) Ok as.String)