Periodic Table of Dispatch Operators

All operators of Scala's marvelous Dispatch library on a single page

Start building a Request from scratch
/\

Empty request, without host, port, path or anything.

:/
(host, port)

A request to be sent to the given host on the given port.

:/
(host)

A request to be sent to the given host, using the default protocol for the type of request.

/
(path)

A request to a given path, without explicitly passing the host and port number. Convenient when the actual location (host and portnumber) is a variable.

url
(url)

Constructs a request for the given URL.

Extend the path
<<?
(values)

Encodes the parameters in the query string.

/
(path)

Appends the given path to the path of the current request.

Pass in content
<<<
(text)

Turns the request into a PUT, sending the text.

PUT
<<<
(file, content_type)

Turns the request into a PUT, sending the contents of the file.

PUT
<<<
(values)

Turns the request into a PUT, sending the name value pairs encoded as an application/x-www-form-urlencoded character data.

PUT
<<
(text)

Turns the request into a POST, sending the text.

POST
<<
(values)

Turns the request into a POST, sending the name value pairs encoded as application/x-www-form-urlencoded character data.

POST
<<
(text, content_type)

Turns the request into a POST, sending the text as content of the given content_type.

POST
<<
(bytes)

Turns the request into a POST, posting the data of the byte array passed in.

POST
Change headers
<:<
(map)

Turns the request into a new request with the maps entries to the headers.

as
(user, passwd)

Turn the request into a request that will perform basic or digest authentication, if the response headers indicate a need to do so.

as_!
(user, passwd)

Turns the request into a request with a basic authentication header, without waiting for a 401 response.

gzip

Sets the "Accept-Encoding: gzip" header.

Set a method
POST

Turns the request into POST request.

PUT

Turns the request into PUT request.

DELETE

Turns the request into DELETE request.

HEAD

Turns the request into HEAD request.

Other Request modifiers
secure

Turns the request into an HTTPS request.

<&
(request)

Merges the details of this request with the details set for another request.

>\
(charset)

Turns the request into a new request setting the default character set to charset.

to_uri

Turns the Request composed so far into a URI.

Handle content in a function
>>
((in, charset) => result)

Constructs a Handler that accepts a function turning the InputStream (in) and characterset (charset) into some other value.

>>
((in) => result)

Constructs a Handler that accepts a function turning the content (available through the in parameter, an InputStream) into some other value.

>~
((source) => result)

Constructs a Handler that accepts a function turning the content (available as a Source object) into some other value.

>-
((text) => result)

Constructs a Handler that accepts a function turning the content (available as a String) into some other value.

>>~
((reader) => result)

Constructs a Handler that accepts a function turning the content (available using the reader) into some other value.

<>
((elem) => result)

Constructs a Handler that accepts a function turning the content (available as elem, an xml.Elem) into some other value.

</>
((nodeseq) => result)

Constructs a Handler that accepts a function turning the content (available as an xml.NodeSeq) into some other value.

>#
((json) => result)

Constructs a Handler that will apply a function to a JSON object model representation of the content in the response.

>|

Constructs a Handler that ignores the response.

Handle content directly
as_source

Constructs a Handler that turns the content into a Source.

as_str

Constructs a Handler that turns the content into a String.

>>>
(out)

Constructs a Handler that writes the content to out.

Process response headers
>:>
((map) => result)

Constructs a Handler that accepts a function turning the headers into some other value.

Handler combinations and chaining
>+
(block)

Constructs a Handler from a function of the original object returning two new Handlers, returning them as a tuple.

~>
((conversion) => result)

>+>
(block)

Constructs a handler that chains two request handlers. First handler returns a second, which may use values obtained by the first. Both are run on the same request.

Set an exception listener
>!
(listener)

Set an exception listener.