我创建了一个http服务器,它处理请求并发送JSON和exe文件作为对get请求的响应。那么我们可以在一个请求中设置多种内容类型吗?
Headers h = new Headers();
h = t.getResponseHeaders();
JSONObject json = new JSONObject();
json.put("version", dirFiles.lastEntry().getKey());
String output = json.toString(); // I want to send this with response
File file = new File(fileName);
h.add("CONTENT-TYPE", "application/octet-stream");
FileInputStream fs = new FileInputStream(file);
final byte[] buffer = new byte[4096];
int count = 0;
while ((count = fs.read(buffer)) >= 0) {
os.write(buffer, 0, count);
}
fs.close();
os.close();