Skip to content

HTTPRequest is an easy-to-use zero dependency Java wrapper to read from a URL. Support for Cookies, proxies, UserAgent, post data and more.

License

Notifications You must be signed in to change notification settings

Konloch/HTTPRequest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8804a51 Β· Jul 16, 2023

History

34 Commits
Feb 20, 2023
Mar 14, 2023
Feb 15, 2023
Feb 21, 2023
Jul 16, 2023
Feb 20, 2023
Feb 26, 2023

Repository files navigation

HTTPRequest

HTTPRequest is an easy-to-use zero dependency Java wrapper to read from a URL.

Support for Cookies, proxies, UserAgent, post data and more.

πŸ’‘ Requirements

  • Java Runtime 1.8 or higher

βš™οΈ How To Add As Library

Add it as a maven dependency or just download the latest release.

<dependency>
  <groupId>com.konloch</groupId>
  <artifactId>HTTPRequest</artifactId>
  <version>2.2.0</version>
</dependency>

πŸ“š Links

πŸ’» How To Use

Simple Request:

HTTPRequest request = new HTTPRequest(new URL("https://google.com/"));
		
ArrayList<String> webpage = request.read();

for(String line : webpage)
    System.out.println(line);

Advanced Request:

HTTPRequest request = new HTTPRequest(new URL("https://google.com/"));
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)));

ArrayList<String> webpage = request.read();
for(String line : webpage)
    System.out.println(line);

for (Map.Entry<String, List<String>> k : request.getLastConnectionHeaders())
    System.out.println("Header Value:" + k.toString());