PhilYoussef
PhilYoussef

Reputation: 313

Easiest way to make http requests in java

I'm looking for a maven artifact or some pre-existing framework that will turn making http requests into a 1 liner. For those familiar with Ruby, I'm thinking about something alomg the lines of Httparty which supports get, put, post... etc.

ex:

Response response = SomeLibrary.get("https://api.google.com/maps")
int code = response.code
String body = response.body

Upvotes: 1

Views: 2129

Answers (2)

csupnig
csupnig

Reputation: 3377

we use apache commons http

    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>

It is very easy and supports many functions altough it is not a one liner.

Upvotes: 2

Christian Kuetbach
Christian Kuetbach

Reputation: 16060

Try this Url.openConnection() and HttpUrlConnection

Upvotes: 1

Related Questions