Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Hoppscotch | 51,625 | 1 | a day ago | 1 | March 22, 2022 | 137 | mit | TypeScript | ||
👽 Open source API development ecosystem - https://hoppscotch.io | ||||||||||
Okhttp | 44,017 | 27,142 | 2,318 | 13 hours ago | 88 | June 27, 2022 | 86 | apache-2.0 | Kotlin | |
Square’s meticulous HTTP client for the JVM, Android, and GraalVM. | ||||||||||
Retrofit | 41,566 | 27,329 | 818 | a day ago | 22 | May 20, 2020 | 187 | apache-2.0 | Java | |
A type-safe HTTP client for Android and the JVM | ||||||||||
Httpie | 27,856 | 1,645 | 42 | 4 days ago | 55 | May 06, 2022 | 146 | bsd-3-clause | Python | |
🥧 HTTPie for Terminal — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. | ||||||||||
Guzzle | 22,518 | 55,713 | 19,631 | 7 days ago | 138 | August 28, 2022 | 15 | mit | PHP | |
Guzzle, an extensible PHP HTTP client | ||||||||||
Aiohttp | 13,575 | 7,355 | 4,894 | 15 hours ago | 220 | November 14, 2021 | 496 | other | Python | |
Asynchronous HTTP client/server framework for asyncio and Python | ||||||||||
Got | 13,069 | 235,715 | 6,429 | 20 hours ago | 162 | September 19, 2022 | 86 | mit | TypeScript | |
🌐 Human-friendly and powerful HTTP request library for Node.js | ||||||||||
Feign | 8,805 | 391 | 189 | 14 hours ago | 42 | July 21, 2022 | 174 | apache-2.0 | Java | |
Feign makes writing java http clients easier | ||||||||||
Http Prompt | 8,718 | 7 | 1 | a month ago | 24 | March 05, 2021 | 53 | mit | Python | |
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie | ||||||||||
Node Fetch | 8,301 | 219,668 | 25,410 | 2 days ago | 86 | July 31, 2022 | 183 | mit | JavaScript | |
A light-weight module that brings the Fetch API to Node.js |
A simple convenience library for using a HttpURLConnection to make requests and access the response.
This library is available under the MIT License.
The http-request library is available from Maven Central.
<dependency>
<groupId>com.github.kevinsawicki</groupId>
<artifactId>http-request</artifactId>
<version>6.0</version>
</dependency>
Not using Maven? Simply copy the HttpRequest class into your project, update the package declaration, and you are good to go.
Javadocs are available here.
See here for a list of known projects using this library.
This library was written to make HTTP requests simple and easy when using a HttpURLConnection
.
Libraries like Apache HttpComponents are great but sometimes
for either simplicity, or perhaps for the environment you are deploying to (Android),
you just want to use a good old-fashioned HttpURLConnection
. This library seeks
to add convenience and common patterns to the act of making HTTP requests such as
a fluid-interface for building requests and support for features such as multipart
requests.
Bottom line: The single goal of this library is to improve the usability of the
HttpURLConnection
class.
None. The goal of this library is to be a single class class with some inner static classes. The test project does require Jetty in order to test requests against an actual HTTP server implementation.
The HttpRequest
class does not throw any checked exceptions, instead all low-level
exceptions are wrapped up in a HttpRequestException
which extends RuntimeException
.
You can access the underlying exception by catching HttpRequestException
and calling
getCause()
which will always return the original IOException
.
No. The underlying HttpUrlConnection
object that each HttpRequest
object wraps has a synchronous API and therefore all methods on HttpRequest
are also synchronous.
Therefore it is important to not use an HttpRequest
object on the main thread
of your application.
Here is a simple Android example of using it from an AsyncTask:
private class DownloadTask extends AsyncTask<String, Long, File> {
protected File doInBackground(String... urls) {
try {
HttpRequest request = HttpRequest.get(urls[0]);
File file = null;
if (request.ok()) {
file = File.createTempFile("download", ".tmp");
request.receive(file);
publishProgress(file.length());
}
return file;
} catch (HttpRequestException exception) {
return null;
}
}
protected void onProgressUpdate(Long... progress) {
Log.d("MyApp", "Downloaded bytes: " + progress[0]);
}
protected void onPostExecute(File file) {
if (file != null)
Log.d("MyApp", "Downloaded file to: " + file.getAbsolutePath());
else
Log.d("MyApp", "Download failed");
}
}
new DownloadTask().execute("http://google.com");
int response = HttpRequest.get("http://google.com").code();
String response = HttpRequest.get("http://google.com").body();
System.out.println("Response was: " + response);
HttpRequest.get("http://google.com").receive(System.out);
HttpRequest request = HttpRequest.get("http://google.com", true, 'q', "baseball gloves", "size", 100);
System.out.println(request.toString()); // GET http://google.com?q=baseball%20gloves&size=100
int[] ids = new int[] { 22, 23 };
HttpRequest request = HttpRequest.get("http://google.com", true, "id", ids);
System.out.println(request.toString()); // GET http://google.com?id[]=22&id[]=23
String contentType = HttpRequest.get("http://google.com")
.accept("application/json") //Sets request header
.contentType(); //Gets response header
System.out.println("Response content type was " + contentType);
int response = HttpRequest.post("http://google.com").send("name=kevin").code();
int response = HttpRequest.get("http://google.com").basic("username", "p4ssw0rd").code();
HttpRequest request = HttpRequest.post("http://google.com");
request.part("status[body]", "Making a multipart request");
request.part("status[image]", new File("/home/kevin/Pictures/ide.png"));
if (request.ok())
System.out.println("Status was updated");
Map<String, String> data = new HashMap<String, String>();
data.put("user", "A User");
data.put("state", "CA");
if (HttpRequest.post("http://google.com").form(data).created())
System.out.println("User was created");
File output = new File("/output/request.out");
HttpRequest.get("http://google.com").receive(output);
File input = new File("/input/data.txt");
int response = HttpRequest.post("http://google.com").send(input).code();
File latest = new File("/data/cache.json");
HttpRequest request = HttpRequest.get("http://google.com");
//Copy response to file
request.receive(latest);
//Store eTag of response
String eTag = request.eTag();
//Later on check if changes exist
boolean unchanged = HttpRequest.get("http://google.com")
.ifNoneMatch(eTag)
.notModified();
HttpRequest request = HttpRequest.get("http://google.com");
//Tell server to gzip response and automatically uncompress
request.acceptGzipEncoding().uncompress(true);
String uncompressed = request.body();
System.out.println("Uncompressed response is: " + uncompressed);
HttpRequest request = HttpRequest.get("https://google.com");
//Accept all certificates
request.trustAllCerts();
//Accept all hostnames
request.trustAllHosts();
HttpRequest request = HttpRequest.get("https://google.com");
//Configure proxy
request.useProxy("localhost", 8080);
//Optional proxy basic authentication
request.proxyBasic("username", "p4ssw0rd");
int code = HttpRequest.get("http://google.com").followRedirects(true).code();
Looking to use this library with OkHttp? Read here.
HttpRequest.setConnectionFactory(new ConnectionFactory() {
public HttpURLConnection create(URL url) throws IOException {
if (!"https".equals(url.getProtocol()))
throw new IOException("Only secure requests are allowed");
return (HttpURLConnection) url.openConnection();
}
public HttpURLConnection create(URL url, Proxy proxy) throws IOException {
if (!"https".equals(url.getProtocol()))
throw new IOException("Only secure requests are allowed");
return (HttpURLConnection) url.openConnection(proxy);
}
});