[英]Empty content-type while downloading file with Jersey client
I'm trying to download a file with the Jersey client. 我正在尝试使用Jersey客户端下载文件。 I'm requesting an API, and I don't have API source code. 我正在请求一个API,但是没有API源代码。 For one URL, the API returns an empty "Content-Type" header (the header is present but empty). 对于一个URL,API返回一个空的“ Content-Type”标头(该标头存在但为空)。 Jersey does not like this: 泽西岛不喜欢这样:
Unable to parse "Content-Type" header value: "" 无法解析“ Content-Type”标头值:“”
I'd like to keep the Jersey client if possible 如果可能,我想保留泽西岛的客户
You can set the Content-Type header manually after you receive the response. 您可以在收到响应后手动设置Content-Type标头。
Response res = target.request().get();
res.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, "application/octect-stream");
InputStream file = res.readEntity(InputStream.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.