Before we get into the source code, I want to point it out again that the entire trick bases on HTTP/1.1 Chunked Encoding at http://www.ietf.org/rfc/rfc2616.txt
A successful use also relies on that all servers between your applications fully comply with the Chunked Encoding and do not cache either request or response. These servers may be proxy, firewall, load balancer, http server, servlet...
Problem
This trick is for a specific situation where two applications (both in your hands) want efficient and convenient communication, and HTTP connection is the only method available between them.
HTTP protocol is well-known as a request-and-response standard over internet. One end sends a HTTP request, and waits the other end to reply a HTTP response. The essentials of half-duplex and one-...