tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Triggering chunked encoding from PHP client
Date Fri, 03 Feb 2017 15:50:46 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I've got a service that has been working quite well for a long time,
and I've been asked to provide some sample PHP code to connect to it.
I've written the code and it connects, etc. just fine, except that
it's waiting for the keep-alive timeout (5s) before completing.

When I connect using a Java client, I can see that Tomcat (through
httpd) is using chunked encoding:

DEBUG: Request properties:
DEBUG:   Accept-Charset: UTF-8, ISO-8859-1, *
DEBUG:   Cache-Control: private, no-cache, no-store, no-transform
DEBUG:   Accept: application/xml, text/xml, text/plain
DEBUG:   User-Agent: My Awesome Java Client
DEBUG:   Pragma: no-cache
DEBUG:   Accept-Encoding: gzip, deflate
DEBUG:   Content-Type: application/xml
DEBUG: Received first response packet after 219ms
DEBUG: Dumping HTTP response headers
DEBUG:   Transfer-Encoding: chunked
DEBUG:   Keep-Alive: timeout=5, max=100
DEBUG:   null: HTTP/1.1 200 OK
DEBUG:   Server: Apache/2.2.22 (Debian)
DEBUG:   Connection: Keep-Alive
DEBUG:   Date: Fri, 03 Feb 2017 15:33:13 GMT
DEBUG:   Content-Type: application/xml;charset=UTF-8
DEBUG: Read response in 7ms

When I use the PHP client, here's what I get in the response headers:

array(6) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(35) "Date: Fri, 03 Feb 2017 15:37:01 GMT"
  [2]=>
  string(30) "Server: Apache/2.2.22 (Debian)"
  [3]=>
  string(30) "Keep-Alive: timeout=5, max=100"
  [4]=>
  string(22) "Connection: Keep-Alive"
  [5]=>
  string(43) "Content-Type: application/xml;charset=UTF-8"
}

Note that there isn't any "Transfer-Encoding: chunked" response header.

I can confirm that the PHP client is making an HTTP/1.1 request (and
the response is using HTTP/1.1 as you can see) but chunked encoding
seems not to be in use, here.

I believe I am sending the same request headers from the PHP client.
Here's what the server is seeing:

2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
========== Request from x.y.113.203
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d] host:
example.com
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
content-length: 135
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
content-type: application/xml
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
user-agent: My Awesome PHP Client
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
accept: application/xml, text/xml, text/plain
2017-02-03 10:44:59,287 [catalina-exec-2] TRACE MyServlet- [1d]
Accept-Charset: UTF-8, ISO-8859-1, *
2017-02-03 10:44:59,288 [catalina-exec-2] TRACE MyServlet- [1d]
Accept-Encoding: gzip, deflate
2017-02-03 10:44:59,288 [catalina-exec-2] TRACE MyServlet- [1d]
Cache-Control: private, no-cache, no-store, no-transform
2017-02-03 10:44:59,288 [catalina-exec-2] TRACE MyServlet- [1d]
pragma: no-cache
2017-02-03 10:44:59,288 [catalina-exec-2] TRACE MyServlet- [1d]
connection: keep-alive

And the same from the Java client:

2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
========== Request from x.y.113.203
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
user-agent: CHADIS-API Example Client (Java)
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
content-type: application/xml
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
accept: application/xml, text/xml, text/plain
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
Accept-Encoding: gzip, deflate
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
Accept-Charset: UTF-8, ISO-8859-1, *
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
Cache-Control: private, no-cache, no-store, no-transform
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
pragma: no-cache
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e] host:
example.com
2017-02-03 10:46:33,684 [catalina-exec-3] TRACE MyServlet- [1e]
connection: keep-alive
2017-02-03 10:46:33,685 [catalina-exec-3] TRACE MyServlet- [1e]
content-length: 135


I'm using the same "call" payload and the response should be identical
for the two clients.

If I add "Connection: close" to the headers from the PHP client then
the call completes immediately without the 5-second delay.

PHP is documented to support chunked encoding, but the server doesn't
look like it's even trying to use chunked encoding, since the response
headers don't say anything about it.

Any ideas as to what might be happening?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYlKbWAAoJEBzwKT+lPKRYRlIQAKnMWIv+hTKTQYxLVrG/CX3A
7abMOCmgOeSuWc2ejNmC4GnIbrObAoDgB874+uNJFJudhUScNMRUtyaVnhtbrvp7
TpBLhpb+y6qNjRjSGGmCmZ5L1S4Z7eoYdZAjXKR2zBKaRSR7mjHGq+yu7HsfjEue
/cum3MDa9fy/5hCi3zfoy7oiRh1yRLLbUq3mXmfP5xblu+BPvJ35Z5bQWrmRU68B
wWwDF6aV6eGaqq/jODnpTJ1N+sw0ifY8UpTeLEmtZnolONfLxG07piUKair2u3Wz
4I/t04a/h6CLRMAUghh6EVnBVo0YbEMx6UFKLsLXAUXcym2sKUGSNPEFnHYBVzpm
HB473o3z21XYpfUnfKv+qnLuPVt0m+HAI93UQWmQo7pnPrSDOl/bMswzWybAXeP4
ObRkdVPofWEmOgUHDas5zzVhJC+QQDvYcterIa5ArmM55wMKdQpOXT0EFP3/XsIu
Y3ad5Th2IGRbECcOO157tigpgrpldgYUmFGnv+SiDffSsK75M6VrK9LjLqiNDIFs
Ti3LT7oNcySPjiarggFyw7YkwwC32jMSfZzXk7qkeqtzXyFllhgNwb9TdSMMTmQg
sG6Wjpq8BAevx8T0y9Zy8D0bt/Sa2ecqseexRm9Mj+wsrKnKo/Ea7p/LBOAwRsMe
KNuYawBkCPhG3plTbfF/
=0zcP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message