I am sending a file to a server as an octet-stream, and I need to specify the filename in the header:
String filename = "«úü¡»¿.doc"
URL url = new URL("http://www.myurl.com");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.addRequestProperty("Accept", "application/json; charset=UTF-8");
conn.addRequestProperty("Content-Type", "application/octet-stream; charset=UTF-8");
conn.addRequestProperty("Filename", filename);
// do more stuff here
The problem is, some of the files I need to send have filenames that contain non-ASCII characters. I have read that you cannot send non-ASCII text in an HTTP header.
My questions are:
- Can you send non-ASCII text in an HTTP header?
- If you can, how do you do this? The code above does not work when filename contains non-ASCII text. The server responds with "Bad Request 400".
- If you cannot, what is the typical way to get around this limitation?