4

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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Hurby
  • 74
  • 1
  • 1
  • 6
  • What are the HTTP headers? – Danny_ds Jan 04 '16 at 16:25
  • 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 – Hurby Jan 05 '16 at 07:14

1 Answers1

5

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.

Community
  • 1
  • 1
Danny_ds
  • 11,201
  • 1
  • 24
  • 46
  • Yes, quite certainly a reverse proxy working on the response, which takes the **first chunk** and transmit it as a complete `HTTP/1.0` response, without replacing the `Transfer-Encoding` header by a `Content-length` header, and without parsing the other chunks. A **bad** proxy. – regilero Jan 05 '16 at 13:51
  • That is exactly what i figured out after the hint of Danny_ds. I was able to inherit the class of the third-party library and implement a custom transport-module which works. @Danny_ds thank you very much – Hurby Jan 06 '16 at 08:38