Upstream: fixed previous commit.

Store r->connection on stack to make sure it's still available if request
finalization happens to actually free request memory.