3

My code looks something like this:

  val r = :/(srv, 80) <:< Map("Cookie" -> "Scale=Scout%20Pro")
  implicit val http = new Http with NoLogging
  val rBeg = r / "endSessionRedirect.do"
  http(rBeg <<? Map("r" -> to) >|)

It works properly, but now I need to route it through a proxy. How can I do this?

Andres Olarte
  • 4,380
  • 3
  • 24
  • 45
  • mmmmh bould you explain further because it is not clear to me where the proxy should come in the game. Do you want something that is able to make url rewriting in the Request directly ? – Andy Petrella Feb 21 '12 at 15:30

2 Answers2

3

You can set a proxy server on the Req object directly in Dispatch 0.11 like:

val r = :/(srv, 80).setProxyServer(new ProxyServer("localhost", 8000)) <:< Map("Cookie" -> "Scale=Scout%20Pro")

Based on my testing (with v0.11.0), Dispatch completely ignores the JVM proxy options.

sralmai
  • 197
  • 1
  • 5
3

I guess it was easier that I though, it is Java underneath after all, so passing the Java proxy options works:

-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8001
dacwe
  • 43,066
  • 12
  • 116
  • 140
Andres Olarte
  • 4,380
  • 3
  • 24
  • 45
  • Thanks for the tip, I tried this with 0.11.0 and it doesn't work. I also tried passing them as JVM arguments without success. Any idea why that might be the case? – Bob Jul 26 '13 at 22:18
  • 3
    This should not be accepted. Dispatch ignores these settings as it use Netty under the hood and Netty ignores it: https://github.com/netty/netty/issues/1133 – mirelon Mar 10 '15 at 14:39