An easy to use pure Java wrapper to read from a URL. Cookie, proxy, useragent, post data, and referrer are easily configurable.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
HTTPRequest.java
LICENSE
README.txt

README.txt

This is a very simple HTTPRequest wrapper I wrote in Java, it currently supports setting post data, cookies, useragent and it has proxy support.

Example:

HTTPRequest request = new HTTPRequest(new URL("http://the.bytecode.club/"));
request.setTimeout(10000);
request.setPostData("postdata=yes&awesome=yup");
request.setReferer("http://google.com/");
request.setCookie("cookies=yes;cool=sure");
request.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 81)));
String[] webpage = request.read();
for (Map.Entry<String, List<String>> k : request.getLastConnectionHeaders())
	System.out.println(k.toString());

Ofcourse you can just create a simple request by doing:

HTTPRequest request = new HTTPRequest(new URL("http://the.bytecode.club/"));
String[] webpage = request.read();

And that will set everything for you automatically.