HTTP: Illegal chunked encoding

岁酱吖の 提交于 2019-12-12 10:02:48

问题


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.

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.

Fiddler shows the following response:

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?


回答1:


The header of the request is as follows:

POST /osci-manager-entry/externalentry HTTP/1.0
Host: [the-host]
Content-Length: 3984
Proxy-Connection: Keep-Alive

The header of the response contains this:

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.

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.

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.

In HTTP/1.0, Keep-Alive and chunked transfer-coding cannot be used together:

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.



来源:https://stackoverflow.com/questions/34593230/http-illegal-chunked-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!