我正在尝试删除spark中的Content-Type标头。这似乎是不可能的,因为当我尝试使用type或header方法将其设置为null时。它只是缺省为text/html。
发布于 2017-08-15 03:19:03
要删除报头中的Content-Type值,请使用空字符串response.type("")设置响应类型。
下面是一个在Spark v2.6.0上工作的代码示例:
public class Main {
public static void main(String[] args) {
get("/hello", new Route() {
@Override
public Object handle(Request request, Response response) throws Exception {
response.type("");
response.body("hello world");
return response;
}
});
}
}Httpie命令输出(http 0.0.0.0:4567/hello):
HTTP/1.1 200 OK
Date: Mon, 14 Aug 2017 19:12:17 GMT
Server: Jetty(9.4.4.v20170414)
Transfer-Encoding: chunked
spark.Response@592d7509https://stackoverflow.com/questions/45440338
复制相似问题