Octet / stream client binary mail client

I would like to record with binary data using the Jersey Client.

The equivalent with curl would be:

curl -v --header "Content-Type:application/octet-stream" --data-binary "abc" http://example.com 

I could not find how to do this in the official docs: http://jersey.java.net/documentation/latest/user-guide.html#client

Thanks.

+6
source share
1 answer

I think you can invoke a POST request with Entity, which encapsulates binary data as follows:

 Client client = ClientBuilder.newClient(); WebTarget webTarget = client.target("http://example.com/rest"); Response response = webTarget.request(MediaType.TEXT_PLAIN_TYPE) .post(Entity.entity("abc", MediaType.APPLICATION_OCTET_STREAM)); 
+6
source

Source: https://habr.com/ru/post/951257/


All Articles