Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Fwd: Jetty Client 9.04 threads

Hi,

On Fri, Jul 19, 2013 at 10:30 AM, Kamil Gorlo <kgorlo@xxxxxxxxx> wrote:
> I am implementing some kind of webcrawler which presents results to
> users. User asks my service to crawl website and then I show some
> report for him.
>
> If users asks me about (malicious) website which will return Location:
> http://<internal_ip_in_my_network>/index.php then I want to block this
> action. How to do this nicely in Jetty? For now, I have turned off
> automatic redirects and implemented them manually and additionally in
> each step I need to resolve returned host from Location header, check
> if it is "safe" and then loop.

newRequest(...)
    ...
    .onResponseHeaders(response -> {
            if (!isRedirectAllowed(response))
                response.abort(new Exception());
    })
    .send(...);

You implement isRedirectAllowed(Response) with your logic, and that
should be it.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top