Hi
I apologize if this question is basic
I want to send binary data using the http post method of the HttpClient
library. Unfortunately the addParameter allows me to set only Strings
How can I achieve the following using HttpClient? Thank you for your help!
public static byte[] compress(byte[] input) {
try {
final ByteArrayOutputStream targetStream = new
ByteArrayOutputStream(input.length);
OutputStream outputStream = new
java.util.zip.GZIPOutputStream(targetStream);
outputStream.write(input);
outputStream.close();
return targetStream.toByteArray();
} catch (IOException e) {
throw new RuntimeException("impossible exception?", e);
}
}
.....
HttpClient client = new HttpClient
PostMethod httpPost = new PostMethod("
http://localhost:8080/httpclienttest/body");
byte[] dataCompressed = compress(data);
hppPost.set("Body", dataCompressed);
client.executeMethod(httpPost);