4

When I'm picking up the response of a site with JSOUP, I can capture all headers except the LOCATION.

With JSOUP or some other html parser there some way to capture the value of the response header "LOCATION"?

Benigno Sales
  • 193
  • 2
  • 6

1 Answers1

6

You can read Location with JSoup.

Real example

Connection.Response response = Jsoup
        .connect("http://tvnwarszawa.pl/d")
        .method(Connection.Method.POST)
        .followRedirects(false)
        .execute();

System.out.println(response.header("Location"));

Output

http://tvnwarszawa.tvn24.pl/d

Read more about Location: http://en.wikipedia.org/wiki/HTTP_location

Maybe you are interested in url()?

System.out.println(response.url());
MariuszS
  • 30,646
  • 12
  • 114
  • 155