'Curl: how data is interpreted by Java InputStream, if I sent it using curl --data-binary?

I have a server, written on Java, which is currently running on a

http://localhost:8080

Source code is hidden from me, but I know that all endpoints are handled by Java HttpExchange class, for example endpoint:

http://localhost:8080/generate/init

will be handled like that:

public void init(HttpExchange httpex) throws IOException {
...
}

The next thing I know is that incoming POST requests are handled like that:

byte post_data = (byte) httpex.getRequestBody().read();

My question is, that when I do from a command-line:

echo -e '\x03' | curl -X POST -i --data-binary @- http://localhost:8080/generate/init

What will be the value of post_data? As I understand curl will send '\x03' exactly as it is:

\x03

And Java HttpExchange method getRequestBody() will return InputStream of it, where read() will translate that InputStream into int. As much as I know, Java doesn't interpret HEX as '\x03', instead it uses Unicode '\u0003'. Therefore I'm afraid of sending wrong data into my server.

If I'm wrong about curl --data-binary, please correct me! I just wish to be sure, that I pass number "3" by POST request and server interprets it as number 3, but in bytes ((byte) 3)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source