Home GET img/png with grails.plugins.rest.client.RestResponse
Reply: 0

GET img/png with grails.plugins.rest.client.RestResponse

user771
1#
user771 Published in May 22, 2018, 4:35 am

I am using grails.plugins.rest.client.RestResponse to GET a binary resource of content-type png from a rest endpoint.

import grails.plugins.rest.client.RestBuilder
import grails.plugins.rest.client.RestResponse

String url = "http://localhost:8080/rest-endpoint/image.png"
RestBuilder rest = new RestBuilder()
RestResponse restResponse = rest.get(url){
    auth username, password
    accept "image/png"
    contentType "image/png"
}

byte[] png_image = restResponse.responseEntity.body
println "length " + png_image.length

I'm not sure why the length that is returned is ~500bytes less than expected and I have tried with a different image and a different url and the length returned is lower everytime. Any idea why?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307061 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO