Code Monkey home page Code Monkey logo

unirest-java's Introduction

Unirest for Java

Actions Status Maven Central Javadocs

Unirest 4

Unirest 4 is build on modern Java standards, and as such requires at least Java 11.

Unirest 4's dependencies are fully modular, and have been moved to new Maven coordinates to avoid conflicts with the previous versions. You can use a maven bom to manage the modules:

Install With Maven

<dependencyManagement>
  <dependencies>
      <!-- https://mvnrepository.com/artifact/com.konghq/unirest-java-bom --> 
      <dependency>
          <groupId>com.konghq</groupId>
          <artifactId>unirest-java-bom</artifactId>
          <version>4.4.0</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.konghq/unirest-java-core -->
    <dependency>
        <groupId>com.konghq</groupId>
        <artifactId>unirest-java-core</artifactId>
    </dependency>
    
    <!-- pick a JSON module if you want to parse JSON include one of these: -->
    <!-- Google GSON -->
    <dependency>
        <groupId>com.konghq</groupId>
        <artifactId>unirest-modules-gson</artifactId>
    </dependency>

    <!-- OR maybe you like Jackson better? -->
    <dependency>
        <groupId>com.konghq</groupId>
        <artifactId>unirest-modules-jackson</artifactId>
    </dependency>
</dependencies>

🚨 Attention JSON users 🚨

Under Unirest 4, core no longer comes with ANY transient dependencies, and because Java itself lacks a JSON parser you MUST declare a JSON implementation if you wish to do object mappings or use Json objects.

Upgrading from Previous Versions

See the Upgrade Guide

ChangeLog

See the Change Log for recent changes.

Documentation

Our Documentation

Unirest 3

Maven

<!-- Pull in as a traditional dependency -->
<dependency>
    <groupId>com.konghq</groupId>
    <artifactId>unirest-java</artifactId>
    <version>3.14.1</version>
</dependency>

unirest-java's People

Contributors

adriens avatar bable5 avatar bedware avatar bludwarf avatar brothhaar avatar daniloglima avatar davidghiurco avatar dependabot[bot] avatar dewos avatar dzikoysk avatar esseguin avatar hakky54 avatar haroon-sheikh avatar iximeow avatar jgalo80 avatar nijikokun avatar pilif avatar redstom avatar ryber avatar saschaszott avatar shashiranjan84 avatar shatsar avatar sonicaghi avatar sreeniio avatar stevespringett avatar subnetmarco avatar tcoxon avatar team-eng-enablement avatar tjkyner avatar varra4u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unirest-java's Issues

Asynchronous requests send file data incorrectly

I noticed uploads to imgur aren't working via asJsonAsync.

Pointing my code at httpbin.org instead of imgur and capturing the output, I noticed there were the following differences in the request:

Synchronous (replacing the actual base64 data with 'blaaahh'):

{"headers":{"Host":"httpbin.org","Content-Length":"22051",
"Accept-Encoding":"gzip","User-Agent":"unirest-java/1.3.6",
"X-Request-Id":"8ea9cda9-8912-4df5-bf21-3760e4c655c5",
"Connection":"close","Content-Type":"multipart/form-data; boundary=PRI5z1h7IjTEQ5a4QykoezbnF2CMVTWl0f"},
"files":{"image":"data:application/octet-stream;base64,blaaahh="},
"form":{},"json":null,"args":{},"origin":"86.26.3.234","data":"",
"url":"http://httpbin.org/post"}

Asynchronous:

{"headers":{"Host":"httpbin.org","Content-Length":"22047",
"Accept-Encoding":"gzip","User-Agent":"unirest-java/1.3.6",
"X-Request-Id":"0bda004c-7ccd-48b4-8239-92e4fef8d8ca","Connection":"close"},"files":{},"form":{},
"json":null,"args":{},"origin":"86.26.3.234",
"data":"data:application/octet-stream;base64,blaaaah",
"url":"http://httpbin.org/post"}

So rather than sending it as a file named 'image', it's sending it in the 'data' field (whatever that is).

My code (scala):

def main(args: Array[String]) {
    syncTest("httpbin", httpbin())
    asyncTest("httpbin", httpbin())
    syncTest("imgur", imgur())
    asyncTest("imgur", imgur())
  }

  def httpbin() =
    Unirest.post("http://httpbin.org/post")
        .field("image", new File("test.gif"))

  def imgur() =
    Unirest.post("https://imgur-apiv3.p.mashape.com/3/image")
        .header("X-Mashape-Authorization", MASHAPE_AUTH)
        .header("Authorization", IMGUR_AUTH)
        .field("image", new File("test.gif"))
        .field("type", "binary")

  def asyncTest(label: String, request: MultipartBody) {
    request
        .asJsonAsync(new Callback[JsonNode] {

          def failed(e: UnirestException) {
            println(label+" async Failed")
          }

          def completed(response: HttpResponse[JsonNode]) {
            println(label+" async "+response.getCode())
            println(label+" async "+response.getHeaders())
            println(label+" async "+response.getBody())
          }

          def cancelled() {
            println(label+" async Cancelled");
          }
        })
  }

  def syncTest(label: String, request: MultipartBody) {
    val response = request.asJson()
    println(label+" sync "+response.getCode())
    println(label+" sync "+response.getHeaders())
    println(label+" sync "+response.getBody())
  }

This sends a file "test.gif" in 4 requests: asynchronous and synchronous requests to httpbin and imgur, but you can remove the imgur requests and see the difference (as above) in just the httpbin requests.

I'm using Unirest 1.3.8 (from the binary here: http://unirest.io/java.html) with httpclient 4.3.2, httpmime 4.3.2, httpasyncclient 4.0.1 on my classpath.

Consider adding a progress listener for Callback

One thing that would make this library even better is to add a simple progress callback that updates as a request is made. For POST/PUT/PATCH etc it would be great for this to monitor upload progress, and for GET/DELETE etc it would be great for download progress. Thoughts? This is another side note, but it would be nice to include a default callback class that provides stubbed implementations of the callback interface for those who don't wish to provide functionality for some of the methods.

Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post")
  .header("accept", "application/json")
  .field("param1", "value1")
  .field("param2", "value2")
  .asJsonAsync(new Callback<JsonNode>() {

    public void failed(UnirestException e) {
        System.out.println("The request has failed");
    }

    public void completed(HttpResponse<JsonNode> response) {
         int code = response.getCode();
         Map<String, String> headers = response.getHeaders();
         JsonNode body = response.getBody();
         InputStream rawBody = response.getRawBody();
    }

    public void cancelled() {
        System.out.println("The request has been cancelled");
    }

    public void progress(long current, long total) {
        System.out.println("Progress: " + ((float)current / (float)total));
    }

});

org.apache.http.ProtocolException if query parameter too long

I'm attempting to make a POST request. However, it's failing with this exception when the length for one of the query strings exceeds ~5285 characters:

com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.ProtocolException: Not a valid protocol version: <html>

The value for the parameter is just some basic HTML (<div>FOO</div> over and over). If I remove just one of those divs, the request will go through successfully, so I'm pretty sure it just can't process a string of this length.

This is the request url that is generated:

https://api.sendgrid.com/api/newsletter/edit.json?api_user=my_username&api_key=my_key&identity=Default&name=test&subject=test&text=test&html=%0A%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Transitional%2F%2FEN%22+%22https%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22+lang%3D%22en%22+xml%3Alang%3D%22en%22%3E%0A++++%3Chead%3E%0A++++++++%3Cmeta+http-equiv%3D%22Content-Type%22+content%3D%22text%2Fhtml%3B+charset%3DUTF-8%22+%2F%3E%0A++++++++%3Ctitle%3EBuy+2+Get+1+Free%3C%2Ftitle%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3Cdiv%3EFOO%3C%2Fdiv%3E%0A++++++++%3C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FOO%3C%2Fdiv%3E%0A++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E

This is the stack trace:

com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.ProtocolException: Not a valid protocol version: <html>
    at com.mashape.unirest.http.HttpClientHelper$1.failed(HttpClientHelper.java:86) [unirest-java-1.3.27.jar:na]
    at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:130) [httpcore-4.3.3.jar:4.3.3]
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.failed(DefaultClientExchangeHandlerImpl.java:258) [httpasyncclient-4.0.2.jar:4.0.2]
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.exception(HttpAsyncRequestExecutor.java:123) [httpcore-nio-4.3.2.jar:4.3.2]
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:273) [httpcore-nio-4.3.2.jar:4.3.2]
Caused by: org.apache.http.ProtocolException: Not a valid protocol version: <html>
    at org.apache.http.impl.nio.codecs.AbstractMessageParser.parse(AbstractMessageParser.java:208) ~[httpcore-nio-4.3.2.jar:4.3.2]
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:245) [httpcore-nio-4.3.2.jar:4.3.2]
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:73) [httpasyncclient-4.0.2.jar:4.0.2]
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:37) [httpasyncclient-4.0.2.jar:4.0.2]
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:120) [httpcore-nio-4.3.2.jar:4.3.2]
Caused by: org.apache.http.ParseException: Not a valid protocol version: <html>
    at org.apache.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:132) ~[httpcore-4.3.3.jar:4.3.3]
    at org.apache.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:361) ~[httpcore-4.3.3.jar:4.3.3]
    at org.apache.http.impl.nio.codecs.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:114) ~[httpcore-nio-4.3.2.jar:4.3.2]
    at org.apache.http.impl.nio.codecs.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:51) ~[httpcore-nio-4.3.2.jar:4.3.2]
    at org.apache.http.impl.nio.codecs.AbstractMessageParser.parseHeadLine(AbstractMessageParser.java:156) ~[httpcore-nio-4.3.2.jar:4.3.2]

BasicAuth

To be consistent with the other libraries should be auth

headers

when getting responses with multiple headers with the same key e.g. "Set-Cookie", only the last entry will show up in response.heeaders since it is a Map<String, String>

Asynchronous Requests not working on Android!

When I use the Sync Request it works, but i should implement it in an Android AsyncTask class, because I can't make network connection in main thread.

When I try to use the Asynchronous Requests, I'm always getting The request has failed!.
I just changed the completed method to get the Json object instead of inputstream.

Did I miss something?

Problem working with Content Coding in response

I'm trying to use your UniRest for Java, but I'm struggling with one (I think) simple problem.
When trying to build a request with a response that has a content coding "ISO-8859-1" response, I got and UnirestException (Caused by: com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.client.ClientProtocolException ==> Caused by: org.apache.http.HttpException: Unsupported Content-Coding: ISO-8859-1).
I've tried adding Content-Encoding and Accept-Encoding as headers in the request, with no luck.
Can you point me out in the right direction on how to solve this ?

Great library, btw :)

Content-Type doesn't seem to be set when using async requests

It seems the Content-Type isn't obeying what I set it to when I make asynchronous requests.

Unirest.post(BASE_URL + "/events")
                .header("Content-Type", "application/json")
                .header("Accept", "application/json")
                .body(gson.toJson(eventMessage)).asJsonAsync();

The same thing occurs when I try using setDefaultHeader. Wireshark reports the following:

POST /events HTTP/1.1
user-agent: unirest-java/1.3.11
accept-encoding: gzip
Accept: application/json
Content-Type: text/plain; charset=UTF-8
Content-Length: 105
Host: localhost:3000
Connection: Keep-Alive

{"player":{"uniqueId":"af0aec62-b005-4327-9499-79dffd1a8f0c","name":"Test"},"type":"PlayerLoggedInEvent"}HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 2
Date: Fri, 19 Dec 2014 02:22:38 GMT
Connection: keep-alive

{}

It does work as expected with synchronous requests, however.

Unirest.post(BASE_URL + "/events")
                .header("Content-Type", "application/json")
                .header("Accept", "application/json")
                .body(gson.toJson(eventMessage)).asJson();
POST /events HTTP/1.1
user-agent: unirest-java/1.3.11
accept-encoding: gzip
Accept: application/json
Content-Type: application/json
Content-Length: 105
Host: localhost:3000
Connection: Keep-Alive

{"player":{"uniqueId":"5ea1a02f-1dea-4866-be58-09b6da238de7","name":"Test"},"type":"PlayerLoggedInEvent"}HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 105
Date: Fri, 19 Dec 2014 02:21:18 GMT
Connection: keep-alive

{"player":{"uniqueId":"5ea1a02f-1dea-4866-be58-09b6da238de7","name":"Test"},"type":"PlayerLoggedInEvent"}

timeouts ignored for Async calls

When testing with the Synchronous API and testing my timeouts I can see both:

SocketTimeoutException: connect timed out

and

SocketTimeoutException: Read timed out

however, when trying the Async calls timeouts are completely ignored

Unable to replace default User-Agent header

It seems that I am unable to completely replace the User-Agent header on a request. The default User-Agent is always present, either before or after mine depending on how it is added.

With
Unirest.post(this.url).header("User-Agent", "myuseragent");, the default one is before.

With Unirest.setDefaultHeader("User-Agent", "myuseragent"); the default one appears after.

I also expected Unirest.clearDefaultHeaders(); to also clear the existing User-Agent but it does not.

testPostRawBody failing on OSX

org.junit.ComparisonFailure: expected:<'"@[���������������]-test-123-0.17736978...> but was:<'"@[???????????????]-test-123-0.17736978...>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest.testPostRawBody(UnirestTest.java:145)

OSX 10.10, Oracle JDK 1.7.0_45
I assume this is a matter of default encoding and I'm not really worried about it, but it does mean inconsistent behavior.

status and statusText

The current HttpResponse has getCode(), I'd rename this to getStatus() and add getStatusText().

Library naming Confusion with Ruby

Ruby has a very very popular library named "unicorn" already. Since this lib also deals with http (the sending not receiving) there will be confusion between the two.It doesn't help either that most people use the same logo you have chosen https://github.com/blog/517-unicorn

Can we get the Ruby lib renamed something more unique or at least less popular?

mvn clean assembly:assembly can't complete

I originally tried compiling with dependencies using maven in windows and got the following errors:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="25" failures="4" name="com.mashape.unirest.test.http.UnirestTest" time="20.095" errors="0" skipped="0">
  <properties>
    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
    <property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.8.0_25\jre\bin"/>
    <property name="java.vm.version" value="25.25-b02"/>
    <property name="java.vm.vendor" value="Oracle Corporation"/>
    <property name="java.vendor.url" value="http://java.oracle.com/"/>
    <property name="path.separator" value=";"/>
    <property name="guice.disable.misplaced.annotation.check" value="true"/>
    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
    <property name="file.encoding.pkg" value="sun.io"/>
    <property name="user.script" value=""/>
    <property name="user.country" value="US"/>
    <property name="sun.java.launcher" value="SUN_STANDARD"/>
    <property name="sun.os.patch.level" value=""/>
    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
    <property name="user.dir" value="C:\Users\torti_000\unirest-java"/>
    <property name="java.runtime.version" value="1.8.0_25-b18"/>
    <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
    <property name="java.endorsed.dirs" value="C:\Program Files\Java\jdk1.8.0_25\jre\lib\endorsed"/>
    <property name="os.arch" value="amd64"/>
    <property name="java.io.tmpdir" value="C:\Users\TORTI_~1\AppData\Local\Temp\"/>
    <property name="line.separator" value="
"/>
    <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
    <property name="user.variant" value=""/>
    <property name="os.name" value="Windows 8.1"/>
    <property name="classworlds.conf" value="C:\Program Files\Apache\apache-maven-3.2.3\bin\m2.conf"/>
    <property name="sun.jnu.encoding" value="Cp1252"/>
    <property name="java.library.path" value="C:\Program Files\Java\jdk1.8.0_25\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Git\cmd;C:\Users\torti_000\Desktop\adb-tools;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files\Apache\apache-maven-3.2.3\bin;C:\Program Files (x86)\Atmel\Flip 3.4.7\bin;."/>
    <property name="java.specification.name" value="Java Platform API Specification"/>
    <property name="java.class.version" value="52.0"/>
    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
    <property name="os.version" value="6.3"/>
    <property name="user.home" value="C:\Users\torti_000"/>
    <property name="user.timezone" value="America/Los_Angeles"/>
    <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
    <property name="java.specification.version" value="1.8"/>
    <property name="file.encoding" value="Cp1252"/>
    <property name="user.name" value="torti_000"/>
    <property name="java.class.path" value="C:\Program Files\Apache\apache-maven-3.2.3\boot\plexus-classworlds-2.5.1.jar"/>
    <property name="java.vm.specification.version" value="1.8"/>
    <property name="sun.arch.data.model" value="64"/>
    <property name="java.home" value="C:\Program Files\Java\jdk1.8.0_25\jre"/>
    <property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher clean assembly:assembly"/>
    <property name="java.specification.vendor" value="Oracle Corporation"/>
    <property name="user.language" value="en"/>
    <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
    <property name="java.vm.info" value="mixed mode"/>
    <property name="java.version" value="1.8.0_25"/>
    <property name="java.ext.dirs" value="C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext;C:\Windows\Sun\Java\lib\ext"/>
    <property name="sun.boot.class.path" value="C:\Program Files\Java\jdk1.8.0_25\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_25\jre\classes"/>
    <property name="sun.stderr.encoding" value="cp437"/>
    <property name="java.vendor" value="Oracle Corporation"/>
    <property name="maven.home" value="C:\Program Files\Apache\apache-maven-3.2.3"/>
    <property name="file.separator" value="\"/>
    <property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
    <property name="sun.cpu.endian" value="little"/>
    <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
    <property name="sun.stdout.encoding" value="cp437"/>
    <property name="sun.desktop" value="windows"/>
    <property name="sun.cpu.isalist" value="amd64"/>
  </properties>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGet" time="1.057"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testCustomUserAgent" time="0.117"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testAsync" time="0.267"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGzip" time="0.128"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testPathParameters2" time="0.108"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testBasicAuth" time="0.134"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGzipAsync" time="0.1"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testSetTimeouts" time="3.383"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGetFields2" time="0.185"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testMultipart" time="0.14">
    <failure message="expected:&lt;This [
is 
a 
test ]
file&gt; but was:&lt;This [
is 
a 
test 
]
file&gt;" type="org.junit.ComparisonFailure">org.junit.ComparisonFailure: expected:&lt;This [
is 
a 
test ]
file&gt; but was:&lt;This [
is 
a 
test 
]
file&gt;
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest.testMultipart(UnirestTest.java:279)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
</failure>
  </testcase>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGetUTF8" time="0.097"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testAsyncCallback" time="0.198"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testRequests" time="0.271"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testQueryAndBodyParameters" time="0.139"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testPostBinaryUTF8" time="0.11">
    <failure message="expected:&lt;This [
is 
a 
test ]
file&gt; but was:&lt;This [
is 
a 
test 
]
file&gt;" type="org.junit.ComparisonFailure">org.junit.ComparisonFailure: expected:&lt;This [
is 
a 
test ]
file&gt; but was:&lt;This [
is 
a 
test 
]
file&gt;
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest.testPostBinaryUTF8(UnirestTest.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
</failure>
  </testcase>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testPostRawBody" time="0.117">
    <failure message="expected:&lt;&apos;&quot;@[こんにちは]-test-123-0.65075844...&gt; but was:&lt;&apos;&quot;@[?????]-test-123-0.65075844...&gt;" type="org.junit.ComparisonFailure">org.junit.ComparisonFailure: expected:&lt;&apos;&quot;@[こんにちは]-test-123-0.65075844...&gt; but was:&lt;&apos;&quot;@[?????]-test-123-0.65075844...&gt;
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest.testPostRawBody(UnirestTest.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
</failure>
  </testcase>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testDeleteBody" time="0.117"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testMissingPathParameter" time="0"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGetFields" time="0.222"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testDelete" time="0.237"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testPostUTF8" time="0.106"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testDefaultHeaders" time="0.348"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testMultipartAsync" time="10.007">
    <failure type="java.lang.AssertionError">java.lang.AssertionError
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertTrue(Assert.java:52)
    at com.mashape.unirest.test.http.UnirestTest.testMultipartAsync(UnirestTest.java:320)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
</failure>
    <system-err>Exception in thread &quot;I/O dispatcher 5&quot; org.junit.ComparisonFailure: expected:&lt;This [
is 
a 
test ]
file&gt; but was:&lt;This [
is 
a 
test 
]
file&gt;
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest$2.completed(UnirestTest.java:306)
    at com.mashape.unirest.http.HttpClientHelper$1.completed(HttpClientHelper.java:82)
    at com.mashape.unirest.http.HttpClientHelper$1.completed(HttpClientHelper.java:75)
    at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:115)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:173)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:355)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:242)
    at org.apache.http.impl.nio.client.LoggingAsyncRequestExecutor.inputReady(LoggingAsyncRequestExecutor.java:87)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:264)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:73)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:37)
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:113)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:159)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:338)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:316)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:277)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:105)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:584)
    at java.lang.Thread.run(Thread.java:745)
</system-err>
  </testcase>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testPathParameters" time="0.107"/>
  <testcase classname="com.mashape.unirest.test.http.UnirestTest" name="testGetMultiple" time="2.4"/>
</testsuite>

Next I eventually got maven working on mac and tried doing it there. Still errors:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="1" time="6.307" errors="0" skipped="0" tests="25" name="com.mashape.unirest.test.http.UnirestTest">
  <properties>
    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
    <property name="sun.boot.library.path" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries"/>
    <property name="java.vm.version" value="20.65-b04-466.1"/>
    <property name="awt.nativeDoubleBuffering" value="true"/>
    <property name="gopherProxySet" value="false"/>
    <property name="mrj.build" value="11M4716"/>
    <property name="java.vm.vendor" value="Apple Inc."/>
    <property name="java.vendor.url" value="http://www.apple.com/"/>
    <property name="path.separator" value=":"/>
    <property name="guice.disable.misplaced.annotation.check" value="true"/>
    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
    <property name="file.encoding.pkg" value="sun.io"/>
    <property name="user.country" value="US"/>
    <property name="sun.java.launcher" value="SUN_STANDARD"/>
    <property name="sun.os.patch.level" value="unknown"/>
    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
    <property name="user.dir" value="/Users/nick.doering/unirest-java"/>
    <property name="java.runtime.version" value="1.6.0_65-b14-466.1-11M4716"/>
    <property name="java.awt.graphicsenv" value="apple.awt.CGraphicsEnvironment"/>
    <property name="java.endorsed.dirs" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed"/>
    <property name="os.arch" value="x86_64"/>
    <property name="java.io.tmpdir" value="/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/"/>
    <property name="line.separator" value="
"/>
    <property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
    <property name="os.name" value="Mac OS X"/>
    <property name="classworlds.conf" value="/usr/local/apache-maven/bin/m2.conf"/>
    <property name="sun.jnu.encoding" value="MacRoman"/>
    <property name="java.library.path" value=".:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
    <property name="java.specification.name" value="Java Platform API Specification"/>
    <property name="java.class.version" value="50.0"/>
    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
    <property name="os.version" value="10.9.4"/>
    <property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="user.home" value="/var/root"/>
    <property name="user.timezone" value="America/Los_Angeles"/>
    <property name="java.awt.printerjob" value="apple.awt.CPrinterJob"/>
    <property name="java.specification.version" value="1.6"/>
    <property name="file.encoding" value="MacRoman"/>
    <property name="user.name" value="root"/>
    <property name="java.class.path" value="/usr/local/apache-maven/boot/plexus-classworlds-2.5.1.jar"/>
    <property name="java.vm.specification.version" value="1.0"/>
    <property name="sun.arch.data.model" value="64"/>
    <property name="java.home" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"/>
    <property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher clean assembly:assembly"/>
    <property name="java.specification.vendor" value="Sun Microsystems Inc."/>
    <property name="user.language" value="en"/>
    <property name="awt.toolkit" value="apple.awt.CToolkit"/>
    <property name="java.vm.info" value="mixed mode"/>
    <property name="java.version" value="1.6.0_65"/>
    <property name="java.ext.dirs" value="/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext"/>
    <property name="sun.boot.class.path" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar"/>
    <property name="java.vendor" value="Apple Inc."/>
    <property name="maven.home" value="/usr/local/apache-maven"/>
    <property name="file.separator" value="/"/>
    <property name="java.vendor.url.bug" value="http://bugreport.apple.com/"/>
    <property name="sun.cpu.endian" value="little"/>
    <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
    <property name="mrj.version" value="1070.1.6.0_65-466.1"/>
    <property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="sun.cpu.isalist" value=""/>
  </properties>
  <testcase time="0.95" classname="com.mashape.unirest.test.http.UnirestTest" name="testGet"/>
  <testcase time="0.151" classname="com.mashape.unirest.test.http.UnirestTest" name="testCustomUserAgent"/>
  <testcase time="0.241" classname="com.mashape.unirest.test.http.UnirestTest" name="testAsync"/>
  <testcase time="0.103" classname="com.mashape.unirest.test.http.UnirestTest" name="testGzip"/>
  <testcase time="0.15" classname="com.mashape.unirest.test.http.UnirestTest" name="testPathParameters2"/>
  <testcase time="0.092" classname="com.mashape.unirest.test.http.UnirestTest" name="testBasicAuth"/>
  <testcase time="0.1" classname="com.mashape.unirest.test.http.UnirestTest" name="testGzipAsync"/>
  <testcase time="1.024" classname="com.mashape.unirest.test.http.UnirestTest" name="testSetTimeouts"/>
  <testcase time="0.182" classname="com.mashape.unirest.test.http.UnirestTest" name="testGetFields2"/>
  <testcase time="0.096" classname="com.mashape.unirest.test.http.UnirestTest" name="testMultipart"/>
  <testcase time="0.085" classname="com.mashape.unirest.test.http.UnirestTest" name="testGetUTF8"/>
  <testcase time="0.176" classname="com.mashape.unirest.test.http.UnirestTest" name="testAsyncCallback"/>
  <testcase time="0.087" classname="com.mashape.unirest.test.http.UnirestTest" name="testRequests"/>
  <testcase time="0.094" classname="com.mashape.unirest.test.http.UnirestTest" name="testQueryAndBodyParameters"/>
  <testcase time="0.089" classname="com.mashape.unirest.test.http.UnirestTest" name="testPostBinaryUTF8"/>
  <testcase time="0.093" classname="com.mashape.unirest.test.http.UnirestTest" name="testPostRawBody">
    <failure message="expected:&lt;&apos;&quot;@[こんにちは]-test-123-0.61520199...&gt; but was:&lt;&apos;&quot;@[?????]-test-123-0.61520199...&gt;" type="org.junit.ComparisonFailure">org.junit.ComparisonFailure: expected:&lt;&apos;&quot;@[こんにちは]-test-123-0.61520199...&gt; but was:&lt;&apos;&quot;@[?????]-test-123-0.61520199...&gt;
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at com.mashape.unirest.test.http.UnirestTest.testPostRawBody(UnirestTest.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
</failure>
  </testcase>
  <testcase time="0.086" classname="com.mashape.unirest.test.http.UnirestTest" name="testDeleteBody"/>
  <testcase time="0" classname="com.mashape.unirest.test.http.UnirestTest" name="testMissingPathParameter"/>
  <testcase time="0.087" classname="com.mashape.unirest.test.http.UnirestTest" name="testGetFields"/>
  <testcase time="0.176" classname="com.mashape.unirest.test.http.UnirestTest" name="testDelete"/>
  <testcase time="0.086" classname="com.mashape.unirest.test.http.UnirestTest" name="testPostUTF8"/>
  <testcase time="0.256" classname="com.mashape.unirest.test.http.UnirestTest" name="testDefaultHeaders"/>
  <testcase time="0.09" classname="com.mashape.unirest.test.http.UnirestTest" name="testMultipartAsync"/>
  <testcase time="0.085" classname="com.mashape.unirest.test.http.UnirestTest" name="testPathParameters"/>
  <testcase time="1.728" classname="com.mashape.unirest.test.http.UnirestTest" name="testGetMultiple"/>
</testsuite>

Custom HttpClient option blocks application shutdown

Calling:

RequestConfig clientConfig = RequestConfig.custom().setConnectTimeout(600000).setSocketTimeout(600000).build();
Unirest.setHttpClient(HttpClientBuilder.create().setDefaultRequestConfig(clientConfig).build());

Which is the default configuration Unirest uses makes the application unable to exit.
8 Threads (I/O dispatcher 1-8) remain running.

Failing to upload file

I'm following your example in CamFind service on Mashape.

When using a remote URL everything works fine. But when trying to upload a file I get the following exception:
SEVERE: Failed to execute request
com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:145)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at com.jungo.image2hashtag.CamFind.processFile(CamFind.java:79)
at com.jungo.image2hashtag.Main.main(Main.java:25)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
at com.mashape.unirest.http.HttpResponse.(HttpResponse.java:102)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:141)
... 3 more
Caused by: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
at com.mashape.unirest.http.JsonNode.(JsonNode.java:51)
at com.mashape.unirest.http.HttpResponse.(HttpResponse.java:93)
... 4 more
Caused by: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
at org.json.JSONArray.(JSONArray.java:105)
at org.json.JSONArray.(JSONArray.java:144)
at com.mashape.unirest.http.JsonNode.(JsonNode.java:48)
... 5 more

If instead, I break all function calls to separate lines, the requests goes to the server and returns with an error stating the the "image" field is empty.

It seems there is a problem with the "field" method when supplying a "File", or the documentation is not up to date.

BTW I had similar issues with the JS version, where in a newer version the API for attaching files was changes from providing a ReadStream to providing the file path.

BR Ygal

Apache Commons Codec incompatibility on Android

Bug submitted to [email protected] by an user and reported here for reference.

In Android the following error occurs:

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String
   at com.mashape.client.http.AuthUtil.generateAuthenticationHeader(AuthUtil.java:42)
    03-30 13:37:21.024: E/AndroidRuntime(5874): FATAL EXCEPTION: main
    03-30 13:37:21.024: E/AndroidRuntime(5874): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.mashape.client.http.AuthUtil.generateAuthenticationHeader(AuthUtil.java:42)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.mashape.client.http.HttpClient.execRequest(HttpClient.java:125)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.mashape.client.http.HttpClient.doRequest(HttpClient.java:77)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.cbox.api.SentimentAnalysisFree.classifytext(SentimentAnalysisFree.java:42)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.cbox.api.AreaAnalyser.start(AreaAnalyser.java:47)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.cbox.test.CBTestActivity.onCreate(CBTestActivity.java:24)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.os.Handler.dispatchMessage(Handler.java:99)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.os.Looper.loop(Looper.java:130)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at android.app.ActivityThread.main(ActivityThread.java:3701)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at java.lang.reflect.Method.invokeNative(Native Method)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at java.lang.reflect.Method.invoke(Method.java:507)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
    03-30 13:37:21.024: E/AndroidRuntime(5874):     at dalvik.system.NativeStart.main(Native Method)

Trying to import Apache Commons Codec version higher than 1.4 doesn't fix it, because the problem occurs
with the pre-built Mashape client library.

Reason is because the android system includes by default Apache Commons Codec 1.2, so the Mashape library is looking
in the default 1.2 version and not in the external 1.4 jar in the android project.

There's a solution which requires to rebuild the Mashape client library to import a custom renamed package
of the Apache Commons Codec v1.4 and Apache http v4.1.3.

java.lang.NoClassDefFoundError: Could not initialize class com.mashape.unirest.http.options.Options

Hello !
$ Here i do have a problem that i can not work out .. for long time
$ I do have all dependencies that unirest-java needs,but i got traces like blow printing form (http://2.minime.sinaapp.com/):


java.lang.NoClassDefFoundError: Could not initialize class com.mashape.unirest.http.options.Options
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:128)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at org.strongme.minime.global.GlobalUtil.getAccessToken(GlobalUtil.java:224)
at org.strongme.minime.global.WeiXinService.getAccessToken(WeiXinService.java:19)
at org.strongme.minime.HomeController.home(HomeController.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:624)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)


What is going on ?

[Request] Set a proxy

Hi,

I would like to be able to sniff using Fiddler some outgoing http/https request but I am unable to setup a proxy using Unirest.

Could you please make this feature?

Thanks

Issue with multipart File Uploads

I observed an error while using Unirest 1.1.0 Java API.

If Unirest.post is used to post a file, it gives following error

at com.mashape.unirest.request.HttpRequestWithBody.field(HttpRequestWithBody.java:44)

Code Used as mentioned below:

Unirest.post("http://httpbin.org/post")
//.field("blabla", "blabla")
.field("file", f).asJson();

Interesting point to note is that if a dummy field is added like .field("blabla", "blabla") error goes away.

org.junit.ComparisonFailure: expected:<This [ is a test ] file> but was:<This [ is a test ] file>

Hello,
I am following this tutorial to use unierst for android:
http://blog.mashape.com/post/69117323931/installing-unirest-java-with-the-maven-assembly-plugin

aftre running git clone command, I have a unirest-java folder
then I run the command
mvn clean assembly:assembly (or)
mvn package

but I am getting this error in both commands

org.junit.ComparisonFailure: expected:<This [ is a test ] file> but was:<This [ is a test ] file>

see the image
screenshot 2014-06-04 19 02 02

Make Unirest.setHttpClient anytime possible

A call to Unirest.setHttpClient(httpClient); will show no effect if any request has already been done. The httpClient won't be set because ClientFactory keeps the first instance.
ClientFactory should directly pull the client from Options class. This makes httpClient exchangeable between requests. Thus, the "caching" is redundant. This can be required because the apache client lib 4.0 beta 3 deprecates DefaultHttpClient and the HttpClient base class provides no methods to modifiy the later object.

What would be nice to have: Possibility to "reset http client to default one".

Non-blocking I/O support

The asynchronous functionality seems to be provided by starting up a new thread for every outgoing request. This could lead to serious resource explosion under heavy load. There has been a lot of work put into supporting asynchronous request in Java already, namely the Ning AsyncHttpClient - https://github.com/AsyncHttpClient/async-http-client. It comes with support for Netty and Grizzly out of the box.

I'd take a look at what Play does for it's WebService (WS) class for example of things done well. Seems like this project and play have a lot of overlapping functionality, and you could likely work together (See https://github.com/playframework/Play20/blob/master/framework/src/play-java/src/main/java/play/libs/WS.java)

Sonatype/Central

Hey guys!

I like the work you're doing -- it has a lot of promise.

Would you be open to pushing unirest up to Sonatype? It can do automatic mirroring and central deployment for you.

Consider throwing an exception if setTimeouts is called after setAsyncHttpClient

I just spent several hours trying to figure out why my custom CloseableHttpAsyncClient didn't seem to work when I passed it to Unirest like so:

Unirest.setAsyncHttpClient(createHttpAsyncClient());

The problem was that I called setTimeouts on the next line which creates a new CloseableHttpAsyncClient and overrides the one I configured in the line above:

Unirest.setAsyncHttpClient(createHttpAsyncClient());
Unirest.setTimeouts(CONNECTION_TIMEOUT, SOCKET_TIMEOUT);

The solution was to simply change to order of the two lines and everything worked:

Unirest.setTimeouts(CONNECTION_TIMEOUT, SOCKET_TIMEOUT);
Unirest.setAsyncHttpClient(createHttpAsyncClient());

It's not so strange when you think of it since CloseableHttpAsyncClient is immutable but it's easy to forget. So my suggestion is that you throw an exception when calling Unirest.setTimeouts(..) if the user has already set a custom CloseableHttpAsyncClient instance.

Multiple fields with the same parameter in a POST.

I am interacting with an API that allows for multiple fields of the same name to be included in a post request. The app is still under development and not available publicly.

HttpResponse<JsonNode> jsonResponse = Unirest.post(url)
                    .header("Authorization", "Token " + apikey)
                    .field("parameter", "value1")
                    .field("parameter", "value2")
                    .asJson();

The problem I am having is that when I have two fields with the same name, unirest only takes the second one and neglects the first one.

Delete HTTP Method

I can't receive jsonString data by using delete method like below.
But get method works.

    Unirest.delete("http://localhost:9090/sso-ws/rest/member")
      .field("jsonString", "{ \"members\" : \"member1\"}")
      .asJson();

"Broken Pipe" error

First of all - thanks for the great work - I really like this library. I however have an issue, when using it I occasionally receive the following error:

com.mashape.unirest.http.exceptions.UnirestException: java.net.SocketException: Broken pipe
com.mashape.unirest.http.exceptions.UnirestException: java.net.SocketException: Broken pipe
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:145)
at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)

The function I'm using to call your library is as follows:

public static int doHTTPPostWithAdditionalHeaders(String data, String url, HashMap<String, String> additionalHeaders) {

try {
    Unirest.setTimeouts(10000, 10000);
    HttpResponse<String> jsonResponse = Unirest.post(url)
            .headers(additionalHeaders)
            .body(data)
            .asString();

    return jsonResponse.getStatus();

} catch (Exception e) {
    System.out.println("doHTTPPostWithAdditionalHeaders failed: "+e.toString());
}
return 0;

}

Any ideas how I might rectify this? Cheers!

Proxy for fiddler

HI,
Can I set proxy for each request?
I want to set up fiddler with my app where I use unirest library.
Does Unirest support proxy config?
I set:

 System.setProperty("http.proxyHost", "127.0.0.1");
        System.setProperty("https.proxyHost", "127.0.0.1");
        System.setProperty("http.proxyPort", "8888");
        System.setProperty("https.proxyPort", "8888");

but it doesn't works. I still can't see traffic form my app.

Thanks for providing great http library for java :)

Querystrings for POST?

I can create query strings via that .fields(Map<String, Object>) method for GET requests, but I can't find anything for POST requests. I checked the source for HttpRequestsWithBody but I'm thinking I missed it.

This is useful for passing stuff like API keys or tokens.

Hangs on 3rd API call (synchronous) inside loop

Not sure if this is the API's fault, but I'll log it here anyway.

Issues reported so far

Test code below:

import com.mashape.unirest.http.*;
import com.mashape.unirest.http.exceptions.UnirestException;

public class HelloMashape {

public static void main(String[] args) throws UnirestException {

    String[] aIP = {"88.2.24.3", "217.13.80.226", "93.188.136.109", "81.17.254.87", "170.149.168.130"};

//      THIS WORKS FINE     
//      for (int i = 0; i < 5; i++) {
//              
//          HttpResponse<String> request = Unirest.get("https://yoda.p.mashape.com/yoda?sentence=You%20will%20learn%20how%20to%20speak%20like%20me%20someday.%20%20Oh%20wait.")
//                .header("X-Mashape-Authorization", "7uo4fXqGd3DyQVMHNCxrnmgPWnHqfHAZ")
//                .asString();
//
//          System.out.println(request.getCode());
//      }

//  THIS HANGS ON 3RD CALL
    for (int i = 0; i < 5; i++) {

        HttpResponse<JsonNode> request = Unirest.get("https://worldtimeiodeveloper.p.mashape.com/ip?ipaddress=" + aIP[i])
            .header("X-Mashape-Authorization", "Yg15XWbmWmPunOy2c5uxtFRXUgWOEX2C")
            .asJson();

        System.out.println(request.getCode());
    }

  }

}

Failed tests: testDelete(com.mashape.unirest.test.http.UnirestTest)

Failed tests:   testDelete(com.mashape.unirest.test.http.UnirestTest): expected:<[name=mark]> but was:<[

build failure with mvn clean assembly:assembly with all dependencies included in the build file

individual test results: at cat com.mashape.unirest.test.http.UnirestTest.txt

at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

Unable to find CloseableHttpClient

I've gone about this several different ways now, and I'm running into roadblocks at each point. Here's the code that calls unirest:

package com.akqa.glass.recipie;

import android.util.Log;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;

//import org.apache.http.HttpResponse;
//import org.shaded.apache.http.HttpHeaders;

public class JSONParser {
    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";
    private static final String TAG = JSONParser.class.getSimpleName();
    // constructor
    public JSONParser() {
    }
    public JSONObject getCamFindJSON(String type, String input) {
        Log.d("PARSER", "Inside Parser");
        /*
         *  Request processing from API
         */
        if(type == "request"){
            try {
                HttpResponse<JsonNode> response = Unirest.post("https://camfind.p.mashape.com/image_requests")
                .header("X-Mashape-Key", "Fhn5jZi5ixmshwnJMy7CGyj5yDCnp15DTQZjsniuwpVHfYHvFJ")
                .field("image_request[image]", new File(input))
                .field("image_request[language]", "en")
                .field("image_request[locale]", "en_US")
                .asJson();
            } catch (UnirestException e) {
                Log.d(TAG, "Couldn't get request");
                e.printStackTrace();
            }
        }
        /*
         *  Receive response from API
         */
        else if(type == "response"){
            try {
                HttpResponse<JsonNode> response = Unirest.get("https://camfind.p.mashape.com/image_responses/" + input)
                .header("X-Mashape-Key", "Fhn5jZi5ixmshwnJMy7CGyj5yDCnp15DTQZjsniuwpVHfYHvFJ")
                .asJson();
            } catch (UnirestException e) {
                Log.d(TAG, "Couldn't get reponse");
                e.printStackTrace();
            }
        }
        /*
         *  Parse Response into readable JSON
         */
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "n");
                Log.d("Raw Data", line);
            }
            is.close();
            json = sb.toString();
        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        }
        // try parse the string to a JSON object
        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            e.printStackTrace();
        } catch (Exception e) {
            Log.e("JSON Parse", "Unknown Error");
            e.printStackTrace();
        }
        // return JSON String
        return jObj;
    }
}

Here is the logcat output:

11-24 16:26:57.473  12605-12856/com.akqa.glass.recipie E/dalvikvm﹕ Could not find class 'org.apache.http.impl.client.CloseableHttpClient', referenced from method com.mashape.unirest.http.Unirest.shutdown
11-24 16:26:57.473  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ VFY: unable to resolve check-cast 453 (Lorg/apache/http/impl/client/CloseableHttpClient;) in Lcom/mashape/unirest/http/Unirest;
11-24 16:26:57.473  12605-12856/com.akqa.glass.recipie D/dalvikvm﹕ VFY: replacing opcode 0x1f at 0x0006
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie I/dalvikvm﹕ Could not find method org.apache.http.client.methods.HttpRequestBase.releaseConnection, referenced from method com.mashape.unirest.http.HttpClientHelper.request
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ VFY: unable to resolve virtual method 1085: Lorg/apache/http/client/methods/HttpRequestBase;.releaseConnection ()V
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0012
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie I/dalvikvm﹕ Could not find method org.apache.http.client.methods.HttpRequestBase.releaseConnection, referenced from method com.mashape.unirest.http.HttpClientHelper.request
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ VFY: unable to resolve virtual method 1085: Lorg/apache/http/client/methods/HttpRequestBase;.releaseConnection ()V
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0021
11-24 16:26:57.481  12605-12856/com.akqa.glass.recipie I/dalvikvm﹕ Could not find method org.apache.http.client.config.RequestConfig.custom, referenced from method com.mashape.unirest.http.options.Options.refresh
11-24 16:26:57.489  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ VFY: unable to resolve static method 1059: Lorg/apache/http/client/config/RequestConfig;.custom ()Lorg/apache/http/client/config/RequestConfig$Builder;
11-24 16:26:57.489  12605-12856/com.akqa.glass.recipie D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0020
11-24 16:26:57.489  12605-12856/com.akqa.glass.recipie D/dalvikvm﹕ DexOpt: unable to opt direct call 0x0701 at 0x49 in Lcom/mashape/unirest/http/options/Options;.refresh
11-24 16:26:57.489  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/mashape/unirest/http/options/Options;
11-24 16:26:57.489  12605-12856/com.akqa.glass.recipie W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x416aabd8)
11-24 16:26:57.496  12605-12856/com.akqa.glass.recipie E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: com.akqa.glass.recipie, PID: 12605
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:314)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:240)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: java.lang.NoClassDefFoundError: org.apache.http.client.config.RequestConfig
            at com.mashape.unirest.http.options.Options.refresh(Options.java:45)
            at com.mashape.unirest.http.options.Options.<clinit>(Options.java:34)
            at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
            at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
            at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
            at com.akqa.glass.recipie.JSONParser.getCamFindJSON(JSONParser.java:41)
            at com.akqa.glass.recipie.RecipIE$CamFindRequest.doInBackground(RecipIE.java:287)
            at com.akqa.glass.recipie.RecipIE$CamFindRequest.doInBackground(RecipIE.java:275)
            at android.os.AsyncTask$2.call(AsyncTask.java:302)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:240)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
11-24 16:26:57.520  12605-12860/com.akqa.glass.recipie D/PARSER﹕ Inside Parser
11-24 16:26:57.520  12605-12860/com.akqa.glass.recipie I/dalvikvm﹕ Rejecting re-init on previously-failed class Lcom/mashape/unirest/http/options/Options; v=0x0
11-24 16:26:57.528  12605-12860/com.akqa.glass.recipie W/dalvikvm﹕ threadid=13: thread exiting with uncaught exception (group=0x416aabd8)
11-24 16:26:57.528  12605-12860/com.akqa.glass.recipie I/Process﹕ Sending signal. PID: 12605 SIG: 9

UnsupportedOperationException: Multipart form entity does not implement #getContent()

I always get an UnsupportedOperationException when I do an async post and one of the fields is a File. Synchronous posts work fine.

Here is my code:
Unirest.post("https://camfind.p.mashape.com/image_requests")
.header("X-Mashape-Authorization", TESTING_KEY)
.field("image_request[locale]", "en_US")
.field("image_request[image]", file)
.asJsonAsync(new Callback() {
....
}

The failed method of my callback is called with this exception:

com.mashape.unirest.http.exceptions.UnirestException: java.lang.UnsupportedOperationException: Multipart form entity does not implement #getContent()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.