HTTP:非法的分块编码

问题描述 投票:1回答:1

我有一个.NET客户端应用程序,它使用第三方库通过http访问服务器。该库引发以下错误:

The server committed a protocol violation. Section=ResponseBody Detail=Response chunk format is invalid

该软件已经安装了数十次,所以我认为它必须是客户系统中的一个问题,我怀疑是它之间的代理。

我用Fiddler得到了第一个提示。在嗅探Fiddler时注意到协议违规:

Illegal chunked encoding. 'MIME-Version: 1.0' is not a hexadecimal number.

Fiddler显示以下响应:

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

如您所见,响应意外停止。

有谁知道问题可能是什么或如何修复他们?

http protocols mime chunked http-1.1
1个回答
3
投票

请求的标题如下:

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

该软件已经安装了数十次,所以我认为它必须是客户系统中的一个问题,我怀疑是它之间的代理。

最有可能的是,问题是由于在这种情况下使用HTTP / 1.0引起的。分块传输和Keep-Alive在HTTP / 1.0中不是标准配置。

在分块传输编码中,每个块应该start with a hexadecimal number指示随后的块的大小。显然这个数字不存在:Illegal chunked encoding. 'MIME-Version: 1.0' is not a hexadecimal number.

在HTTP / 1.0中,Keep-Alive和chunked transfer-coding cannot be used together

HTTP / 1.1服务器还可以在收到Keep-Alive连接令牌时与HTTP / 1.0客户端建立持久连接。但是,与HTTP / 1.0客户端的持久连接不能使用分块传输编码,因此必须使用Content-Length来标记每个消息的结束边界。

© www.soinside.com 2019 - 2024. All rights reserved.