August 19, 2019
Sharing is Caring: Open-Source Project by CoreValue
The idea behind
We heavily use HTTP clients on a daily basis, it’s a constituent part of our routine work. This is a viable tool to work with the HyperText Transfer Protocol (HTTP). Starting from Java 11 release, we often use Java native HTTP/2 Client. Our development engineers experienced every aspect of this standard HTTP Client and found a couple of things to improve. We analyzed the work we need to do every day and created a wrapper that simplifies our code, considerably saves our time and makes the coding process nice and easy. We named our wrapper after the famous cURL, Client URL, added our company’s values to it and got cVurl, CoreValue URL.
Initially, we made this wrapper for our internal usage to ease our regular workflow. But for us, at CoreValue, the community is not just a word, it means a lot. Also, given the fact that our cVurl is built with Java which philosophy is based on information sharing and helping each other. Google and Amazon are known as the best companies because they share their products. Microsoft opened 60,000 patents for free usage last year. There are a number of Nike and Netflix open-source products. It is simply cool to develop your own products and share them with the world. This idea is only natural for our company and CoreValue contributes to it by making its wrapper an open-source.
How we developed an open-source wrapper
When working on cVurl, we aimed at two things Java native HTTP/2 Client lacked:
1. Simplified API
Surprisingly, our team found out that it [Java native HTTP/2 Client] was not up-to-date with the modern Java trends, and there were a couple of things one couldn’t perform with the standard HTTP Client (without tons of boilerplate). This needed to be changed. So, our cVurl wrapper won’t add dozens of transitive dependencies to your project, it will take off verbosity and let you work with the code in a more functional way.
Our main goal was to make the user’s workflow easier without limitations. That is why we built our API in a way it suits every case and allows the same things the standard API allows, just in a more elegant and simple way.
Here is how POST request looks like with plain Java 11 and cVurl:
2. Addition of missing parts
In Java 11 HTTP/2 Client we identified some missing parts we desperately needed for our work. There was no straightforward way to operate a couple of actions, so we added them in cVurl. Those include:
Formdata. We took off verbosity when sending and implementation of POST requests which require “application/x-www-form-urlencoded” header. With our API you don’t need to create and add several lines of code.
Compression. cVurl checks if a resource is compressed in gzip and decompresses the response. The Java 11 HTTP Client does not work with compressed responses and does not request them by default, so you have to face ugly ctrl+c/v classes to achieve the same.
Multipart. We need to add extra information to the POST request for binary data. With Java 11 HTTP Client you have to build it from scratch. cVurl saves you time and effort as dozens of code lines are not needed anymore.
The cVurl project was made possible with the help and support of our R&D department Coresearch.
Looks interesting? Give it a try! Here is the GitHub page of our open-source wrapper for a Java HTTP/2 Client cVurl. You are welcome to follow, like, use it in your project and share your feedback with us.