Everything you always wanted to know about HTTP (but were afraid to ask).

How to save a binary file?

    final String link =
        "https://repo1.maven.org/maven2" +

    HttpResponse response = HttpRequest

    byte[] bytes = response.bodyBytes();

        new File(SystemUtil.userHome(), "jodd-http.jar"), bytes);

How to follow multi redirects?

HttpRequest by default does not follow the redirect instruction sent in response. You can use HttpBrowser:

    HttpBrowser browser = new HttpBrowser();


    // read response
    Response response = browser.getResponse();
    String page = browser.getPage();

Since v4 the HttpRequest has the flag followRedirects() to enable following the redirects:

    HttpResponse response =

What is the difference between HttpRequest and HttpBrowser?

HttpRequest represents just a single request; clean and simple.

HttpBrowser emulates browsing of a website (i.e. set of URLs) like a browser. Besides sending requests, it also stores and resends cookies, maintaining the current user session. Moreover, the HttpBrowser uses new request on redirection following, allows common request headers for all the requests etc.