title: Get Jetty HttpClient to follow redirects
body: <p>I've got a program that uses Jetty version 8 to send an http post.  My response handler works, but I'm getting an http response code 303, which is a redirect.  I read a comment that jetty 8 has support for following these redirects, but I can not figure out how to set it up.  I've tried looking at the <a href="http://download.eclipse.org/jetty/stable-8/apidocs/org/eclipse/jetty/client/package-summary.html" rel="nofollow">javadocs</a>, and I found the RedirectListener class, but no details on how to use it.  My attempts at guessing how to code it haven't worked so I'm stuck.  All help is appreciated!</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I looked through the jetty source code and found that it will only redirect when the response code is either 301 or 302.  I was able to override the RedirectListener to get it to handle repose code 303 as well.  After that Joakim's code works perfectly.</p>
  
  <pre><code>public class MyRedirectListener extends RedirectListener
  {
     public MyRedirectListener(HttpDestination destination, HttpExchange ex)
     {
        super(destination, ex);
     }
  
     @Override
     public void onResponseStatus(Buffer version, int status, Buffer reason)
         throws IOException
     {
        // Since the default RedirectListener only cares about http
        // response codes 301 and 302, we override this method and
        // trick the super class into handling this case for us.
        if (status == HttpStatus.SEE_OTHER_303)
           status = HttpStatus.MOVED_TEMPORARILY_302;
  
        super.onResponseStatus(version,status,reason);
     }
  }
  </code></pre>