java - Scala Play WS.put Array[Bytes] setting negative bytes to 0b111111 -
i doing http put of array[byte] using play's web service client. reason, setting negative bytes 63 (0b111111). sent same byte stream using java's http stuff , sent on byte array properly. hints?
here example:
//play web service send bytes val bytes = array[byte](0, -3, 2, ...) ws.url(httpservice).put(bytes) //java send bytes val j = new url(httpservice) val con = j.openconnection().asinstanceof[httpurlconnection] con.setdooutput(true) con.setrequestmethod("put") val out = con.getoutputstream.asinstanceof[bytearrayoutputstream] out.write(bytes) out.close() val input = con.getinputstream while (input.available() > 0) input.read() input.close() con.disconnect()
i had set character set iso-8859-1. in general better use base64 send byte array on line; however, couldn't in context of problem. below example of solution. note, setting content type application/octet-stream before , didn't work. fix charset=iso-8859-1 addition.
ws.url(url).withheaders("content-type" -> "application/octet-stream;charset=iso-8859-1")
Comments
Post a Comment