HTTP:非法分块编码 [英] HTTP: Illegal chunked encoding
问题描述
我有一个.NET客户端应用程序,该应用程序使用第三方库通过http访问服务器.该库将引发以下错误:
I have a .NET client-application which uses a third-party library to access a server via http. The library throws the following error:
The server committed a protocol violation. Section=ResponseBody Detail=Response chunk format is invalid
该软件已经安装了数十次,因此我认为它一定是客户系统中的一个问题,我怀疑是两者之间的代理.
The software is already installed dozens of times, so i think it must be an issue in the customers system, my suspicion is the proxy between.
我已经使用Fiddler来获得第一个提示.嗅探提琴手时发现协议违规:
I have used Fiddler to get a first hint. While sniffing Fiddler notice a protocol violation:
Illegal chunked encoding. 'MIME-Version: 1.0' is not a hexadecimal number.
提琴手显示以下响应:
MIME-Version: 1.0
Content-Type: Multipart/Related; boundary=MIME_boundary_RsidtvFKHs9ymusS/NI6l56qcD8r76ye; type=text/xml
--MIME_boundary_RsidtvFKHs9ymusS/NI6l56qcD8r76ye
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <osci@message>
Content-Length: 1545
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ soapMessageEncrypted.xsd http://www.w3.org/2000/09/xmldsig# oscisig.xsd http://www.w3.org/2001/04/xmlenc# oscienc.xsd"><soap:Body><xenc:EncryptedData MimeType="Multipart/Related"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></xenc:EncryptionMethod><ds:KeyInfo><xenc:EncryptedKey><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"></xenc:EncryptionMethod><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIID0jCCArqgAwIBAgIJAMg6MGbE+zZRMA0GCSqGSIb3DQEBDQUAMIGJMQswCQYDVQQGEwJERTEf
MB0GA1UECAwWTWVja2xlbmJ1cmctVm9ycG9tbWVybjERMA8GA1UEBwwIU2Nod2VyaW4xLDAqBgNV
BAoMI0NvbXB1dGVyLUJlcm
您可以看到响应意外停止.
As you can see the response stopped unexpectedly.
有人知道这个问题可能是什么或如何解决?
Does anyone know what the issue might be or how to fix em?
推荐答案
请求的标题如下:
POST /osci-manager-entry/externalentry HTTP/1.0
Host: [the-host]
Content-Length: 3984
Proxy-Connection: Keep-Alive
响应的标题包含以下内容:
HTTP/1.0 200 OK
Date: Mon, 04 Jan 2016 12:10:31 GMT
Transfer-Encoding: chunked
Content-Type: text/plain; charset=iso-8859-1
Connection: Keep-Alive
该软件已经安装了数十次,所以我认为必须 成为客户系统中的一个问题,我怀疑是代理 之间.
The software is already installed dozens of times, so i think it must be an issue in the customers system, my suspicion is the proxy between.
在这种情况下,问题很可能是由于使用HTTP/ 1.0 引起的.分块传输和保持活动在HTTP/1.0中不是标准的.
Most likely, the problem is caused by the usage of HTTP/1.0 in this case. Chunked transfer and Keep-Alive are not standard in HTTP/1.0.
在分块传输编码中,每个块应以十六进制数字开头,指示大小紧随其后的块.显然,这里没有数字:Illegal chunked encoding. 'MIME-Version: 1.0' is not a hexadecimal number.
In chunked transfer encoding, each chunk should start with a hexadecimal number indicating the size of the chunk that follows. Obviously that number is not present here: Illegal chunked encoding. 'MIME-Version: 1.0' is not a hexadecimal number.
在HTTP/1.0中,不能使用Keep-Alive和分块传输编码在一起:
In HTTP/1.0, Keep-Alive and chunked transfer-coding cannot be used together:
HTTP/1.1服务器还可以与 收到Keep-Alive连接令牌后的HTTP/1.0客户端. 但是,与HTTP/1.0客户端的持久连接无法建立 使用分块的传输编码,因此必须使用 Content-Length,用于标记每条消息的结束边界.
An HTTP/1.1 server may also establish persistent connections with HTTP/1.0 clients upon receipt of a Keep-Alive connection token. However, a persistent connection with an HTTP/1.0 client cannot make use of the chunked transfer-coding, and therefore MUST use a Content-Length for marking the ending boundary of each message.
这篇关于HTTP:非法分块编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!