Mendelson AS2 does not set Content-Length when we sent connection close for Async MDN

When an Async MDN is request with the following request headers:

POST /as2/HttpReceiver HTTP/1.1
Receipt-delivery-option: http://localhost:8080/as2/mdn
Content-Description: S/MIME Encrypted Message
MIME-Version: 1.0
AS2-To: mycompanyAS2
Subject: TestMDNRole
Message-Id: <8285f014-d04d-415a-b5d1-fe4d42765e94@Test>
Content-Transfer-Encoding: base64
Connection: close
Date: Mon, 26 Feb 2018 11:24:52 GMT
AS2-Version: 1.2
AS2-From: Test
Content-Disposition: attachment
Content-Type: application/pkcs7-mime; name=smime.p7m; smime-type=enveloped-data
Accept: */*
Content-Length: 6480
Host: localhost:9090
User-Agent: AHC/1.0

The mendelson AS2 sends back the following response:

HTTP/1.1 200 OK
Connection: close
Server: Jetty(9.2.9.v20150224)

The request is sent via a proxy ( and the AHC client goes into a timeout when trying to read the response content.
"Read timeout to localhost/ of 10000 ms."

Is there any particular reason why the Content-Length header is not set?

The issue happens only when the connection header value is set to close and mendelson as2 responds with a connection: close header. When the connection header value is set to Keep-Alive: we get the below response:

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Server: Jetty(9.2.9.v20150224)


With this response we are not facing the same issue.



Profile picture for user service


the second sample you posted does not have a content-length header either - this seems not to be the problem as no content-length is required if there is no content. And this is just a HTTP status that is transmitted. Perhaps a problem with your proxy because of the "Connection: close"?



In the second response there is actually a content which the proxy is able to handle.

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Server: Jetty(9.2.9.v20150224)


But in the first response the content-length is -1 and the response stream in not empty, while reading this stream the client time out. We want to check if the root cause is the proxy.