Questions tagged [scala-dispatch]

Dispatch is a library for asynchronous HTTP interaction. It provides a Scala vocabulary for Java’s async-http-client.

Dispatch is a library for asynchronous HTTP interaction. It provides a Scala vocabulary for Java’s async-http-client.

http://dispatch.databinder.net/Dispatch.html

91 questions
9
votes
2 answers

Basic usage of Dispatch 0.9

I want to POST to a URL, setting query parameters and headers and passing a raw string in the body. I then want to do the request and get the output string, so that i can convert it to JSON. I also want exception handling to respond to different…
Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202
8
votes
2 answers

How do I use Scala dispatch to get the URL returned in a 301 redirect?

I am using Scala dispatch HTTP library, version 0.10.1. I make a request to a URL that returns an HTTP 301, permanent redirect. For example, http://wikipedia.com returns a 301 that redirects to http://www.wikipedia.org/. How do I do I use dispatch…
W.P. McNeill
  • 16,336
  • 12
  • 75
  • 111
7
votes
3 answers

Scala Dispatch library: how to handle connection failure or timeout?

I've been using the Databinder Dispatch library in a client for a simple REST-ish API. I know how to detect if I get an HTTP response with an error status: Http x (request) { case (200, _, _, content) => successResult(content()) case (404,…
Eli Bishop
  • 216
  • 3
  • 6
7
votes
1 answer

How do you parse a JSON request with Dispatch?

I'm learning Scala, and attempting to understand how traits are working (specifically with the Dispatch library). I've got something like this: import dispatch._ import dispatch.liftjson._ object Foo { def main(cmd: Array[String]) { …
David Cramer
  • 1,990
  • 14
  • 24
7
votes
1 answer

How do I get the value of a failed request in Dispatch?

When I make a request in Dispatch, I apply the Promise and get this: Left(dispatch.StatusCode: Unexpected response status: 400) How do I get the actual text of the response? I'm using Solr and it still returns valuable JSON with failed HTTP…
Neil
  • 24,551
  • 15
  • 60
  • 81
6
votes
3 answers

Scala dispatch GET request, fail to parse response to json

im writing a function that : 1) send HTTP GET request (response is a valid JSON) 2) parse the response to a json object code snippet : val page = url("http://graph.facebook.com/9098498615") val response = Http(page OK…
Nimrod007
  • 9,825
  • 8
  • 48
  • 71
6
votes
2 answers

use dispatch 0.9.5 behind proxy?

I'm trying to execute (in IntelliJ IDE or from sbt command-line) this very basic dispatch snippet from behind a proxy : import dispatch._ val svc = url("http://api.hostip.info/country.php") val country = Http(svc > as.String) println(country()) and…
Jerome ROBERT
  • 319
  • 4
  • 12
6
votes
3 answers

Setting User-Agent Header in Scala with Databinders Dispatch Library

Does anyone know how to do this?
Jack Widman
5
votes
2 answers

How to mock Dispatch http client in Scala test?

I've got some code dealing with HTTP requests and I want to unit-test it. Thus I'm trying to mock dispatch.Http or even better dispatch.HttpExecutor (0.8.5) with Scala (2.9.1.final), Mockito (1.9.0-rc1) and ScalaTest (1.6.1) but even can't make my…
aka_sh
  • 549
  • 1
  • 7
  • 18
5
votes
2 answers

HTTPS POST with Scala and Dispatch

I am trying to do a HTTPS post with scala and the Dispatch library. I can't find where to mark my connection as being https not http. Here is the code I have so far println("Running Test") val http = new Http val req = :/("www.example.com" , 443) /…
dkhenry
  • 257
  • 4
  • 11
5
votes
1 answer

how to extract from dispatch.json.JsObject

What do i need to do to extract the value for friends_count. i noticed that screen_name are already define in the Status object and case class. Do still require to extends Js or JsObject different object TweetDetails extends Js { val friends_count…
user365916
5
votes
1 answer

Where to put dispatch.Http.shutdown()

where to place the call to dispatch.Http.shutdown() if there are n independent Http calls like, for example: import com.typesafe.scalalogging.slf4j.Logging import org.json4s._ import org.json4s.native.JsonMethods._ import scala.util.{ Failure,…
nemron
  • 701
  • 6
  • 23
5
votes
2 answers

How to print http request when using Dispatch and Scala

When I am using Dispatch library and Scala, for debugging purpose, how to print out the entire HTTP request with headers, etc. in text after writing a statement like this ? val svc = url("http://api.hostip.info/country.php")
Lex Lian
  • 585
  • 3
  • 12
5
votes
1 answer

How to pass %2f to java.net.URI without it being turned into /

I'm using Dispatch from Scala as follows: val body = """{"count":5,"requeue":true,"encoding":"auto","truncate":50000}""" val req = url("http://localhost:4567/api/queues/%2f/myQueue/get").as_!("guest", "guest") << (body, "application/json") val http…
Blake
  • 71
  • 4
5
votes
2 answers

Send certificate file with Scala Dispatch

I need to be able to send a certificate file (.pem, I think), with a get request using scala and dispatch. How do you do that?
user1491739
  • 1,017
  • 2
  • 11
  • 16
1
2 3 4 5 6 7