Skip to content
A Java library that simplifies the process of sending HTTP requests and handling their responses
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


HTTPicnic is a Java library that greatly simplifies the process of sending HTTP requests and handling their responses.

View the Javadocs here




The HttpRequest class is an abstract class that is used to send basic HTTP requests.

When creating a new request, the URL that the request will be sent to is defined in the constructor.

HttpRequest request = new HttpPost("");

Headers and parameters can then added to the request. An HttpConnectionException will be thrown if there is a problem connecting to the server.

HttpRequest request = new HttpRequest("");
request.addHeader(HttpHeader.ACCEPT, "text/html");
request.addParameter("username", "henry");
request.addParameter("password", "password123");
HttpResponse response = request.sendPOST();

The HttpResponse object contains all the data that the web server replied with.


The PicnicClient class is used to send multiple HTTP requests. It handles the cookies from each request and is useful in cases where cookies need to be stored and sent in every request.

PicnicClient client = new PicnicClient();
client.addParameter("username", "henry");
client.addParameter("password", "password123");
HttpResponse response = client.sendGET("");

In this scenario the goal would be to access a control panel that requires the user to be logged in to view. To accomplish this we would send a POST request to the login page which would respond with a session cookie. The PicnicClient class handles the session cookie and sends it with the next GET request to the user's control panel to show the server that the user is logged in.

You can’t perform that action at this time.