[英]org.glassfish.jersey.message.internal.HeaderValueException: Unable to parse “Content-Type” header value: “multipart/byteranges”
I am trying to get multipart range byte from AWS cloudfront by using InvocationBuilder.header
like:我正在尝试使用InvocationBuilder.header
从 AWS cloudfront 获取多部分范围字节,例如:
invocationBuilder.header("Range", "bytes=100-200,300-400,500-600\r");
but I got this :但我得到了这个:
Exception in thread "Name of the thread" org.glassfish.jersey.message.internal.HeaderValueException: Unable to parse "Content-Type" header value: "multipart/byteranges; boundary=CloudFront:*number of file*"
Internal.InboundMessageContext.exception(InboundMessageContext.java:335)
at org.glassfish.jersey.message.internal.InboundMessageContext.singleHeader(InboundMessageContext.java:330)
at org.glassfish.jersey.message.internal.InboundMessageContext.getMediaType(InboundMessageContext.java:444)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:847)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:785)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
I tried to use curl from cmd and it works well.我尝试使用 cmd 中的 curl 并且效果很好。 Anyone helps?有人帮忙吗? Thanks.谢谢。
CloudFront returns an invalid content-type header in their response to MultiPart range requests. CloudFront 在其对 MultiPart 范围请求的响应中返回无效的内容类型标头。
Specifically, the boundary parameter value contains a ":" which MUST be quoted.具体来说,边界参数值包含一个必须被引用的“:”。
I've just filed a bug with AWS, but we'll see what happens.我刚刚向 AWS 提交了一个错误,但我们会看看会发生什么。 That your original question is 5 years old does not fill me with confidence 😬.你原来的问题是 5 岁并没有让我充满信心😬。
Example MultiPart request:示例 MultiPart 请求:
$ curl -vv https://foo.cloudfront.net/bar.bin -H "Range: bytes=1-100,150-200"
<snip>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 206
< content-type: multipart/byteranges; boundary=CloudFront:32FA314F82E87793C3B34E2D1FCCE8ED
<snip>
Since they include a colon in their boundary parameter, then the parameter must be quoted like this:由于它们在其边界参数中包含一个冒号,因此必须像这样引用该参数:
< content-type: multipart/byteranges; boundary="CloudFront:32FA314F82E87793C3B34E2D1FCCE8ED"
This is according to RFC1521这是根据RFC1521
WARNING TO IMPLEMENTORS: The grammar for parameters on the Content-对实施者的警告:内容上参数的语法-
type field is such that it is often necessary to enclose the类型字段是这样的,通常需要将
boundaries in quotes on the Content-type line.内容类型行上引号中的边界。 This is not always这并不总是
necessary, but never hurts.必要的,但从不伤害。 Implementors should be sure to study the grammar carefully in order to avoid producing illegal Content-type实现者一定要仔细研究语法,以免产生非法的Content-type
fields.领域。 Thus, a typical multipart Content-Type header field might因此,典型的多部分 Content-Type 头字段可能
look like this:看起来像这样:Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p
But the following is illegal:但以下是非法的:
Content-Type: multipart/mixed; boundary=gc0p4Jq0M:2Yt08jU534c0p
(because of the colon) and must instead be represented as (因为冒号)并且必须改为表示为
Content-Type: multipart/mixed; boundary="gc0p4Jq0M:2Yt08jU534c0p"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.