0

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
PhilYoussef
  • 193
  • 2
  • 9
  • possible duplicate of [How to send HTTP request in java?](http://stackoverflow.com/questions/1359689/how-to-send-http-request-in-java) – NimChimpsky Apr 24 '12 at 15:25
  • You can forget about one-liners, it seems :) All the suggestions below are trying to be very complete implementations. But I'd suggest starting with the JDK's `HttpUrlConnection` and writing your own small API around it. – Marko Topolnik Apr 24 '12 at 15:55

2 Answers2

2

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.

csupnig
  • 3,244
  • 1
  • 22
  • 22
1

Try this Url.openConnection() and HttpUrlConnection

Christian Kuetbach
  • 15,171
  • 4
  • 37
  • 74