Quantcast

disable redirection

classic Classic list List threaded Threaded
4 messages Options
dan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

disable redirection

dan
Hi,
Is there a way to disable redirects?  I just want to capture the redirect URL w/o actually loading the page.

Thanks!
dan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable redirection

dan
This works:
 val http = new Http {
            override def make_client = {
              val client = new ConfiguredHttpClient
              HttpClientParams.setRedirecting(client.getParams(), false)
              client
            }
          }

Just wondering if there's a more elegant solution.

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable redirection

efleming969
I need the same thing, but the code posted doesn't compile.

Basically I'm testing an Unfiltered plan and want to verify a redirect status code (not follow the redirect).  Any advice?

Scala: 2.8.1
Dispatch: 0.8.3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable redirection

n8han
Administrator
Sure, the interfaces for that changed in HttpClient. Now it's setRedirectStrategy. You can see the one that is set in the default Dispatch client:
http://sourced.implicit.ly/net.databinder/dispatch-http/0.8.3/ConfiguredHttpClient.scala.html

In your make_client override, you can create a ConfiguredHttpClient and then reset the redirect strategy to one that doesn't redirect at all. Just always return false from isRedirected.

Nathan
Loading...