http: fix stalled pipeline bug (v3.x backport)
Backport of https://github.com/nodejs/node/pull/3342 / ab03635f, only including _http_outgoing.js changes as per @indutny's suggestion. cherry-pick wasn't clean so doing this as a new commit.
/R=@indutny
Original commit ab03635:
This is a two-part fix:
- Fix pending data notification in `OutgoingMessage` to notify server
about flushed data too
- Fix pause/resume behavior for the consumed socket. `resume` event is
emitted on a next tick, and `socket._paused` can already be `true` at
this time. Pause the socket again to avoid PAUSED error on parser.
Fix: https://github.com/nodejs/node/issues/3332
PR-URL: https://github.com/nodejs/node/pull/3342
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>