ngmoco/falcore — pull request #36 by dgrijalva (2012-09-20 23:47:58+00:00)
Title: Upstream copies request instead of passing it thru

We kept running into issues with connection management and content lengths. The root cause seems to be that an http.Response read from the wire is not setup to be written back to the wire. After fighting with prematurely closed downstream connections, duplicated status codes, and numerous content-lenght issues, it seems we shouldn't be reusing that object.

This patch fixes several issues by creating a new response and copying over the appropriate bits. It also applies sane logic to content-length and transfer-encoding.

For example, an upstream that uses connection closing to terminate a response body (for shame) will no longer cause the downstream connection to be shut. Instead, this will be converted to a chunk encoded message on the downstream and keepalives can happily be observed.