Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a proxy server when using dispatch.Http?

Tags:

scala

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?

like image 247
Andres Olarte Avatar asked Dec 04 '25 02:12

Andres Olarte


2 Answers

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
like image 91
Andres Olarte Avatar answered Dec 05 '25 23:12

Andres Olarte


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.

like image 25
sralmai Avatar answered Dec 05 '25 21:12

sralmai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!