Skip to content

Fix pause before response arrives - #1569

Merged
simov merged 1 commit into
request:masterfrom
kevinoid:fix-gzip-pause
May 11, 2015
Merged

simov merged 1 commit into
request:masterfrom
kevinoid:fix-gzip-pause

Conversation

@kevinoid

@kevinoid kevinoid commented May 8, 2015

Copy link
Copy Markdown
Contributor

This PR fixes a bit of fallout due to overlooking the pause behavior before the response arrives in #1568 last night. I added some additional tests which should help catch similar issues in the future.

If anyone has ideas for how to avoid the arbitrary setTimeouts when testing pause/resume, that would be great (currently it waits a bit between sending chunks to allow pausing and waits a bit more after calling pause to confirm no more data arrives). Also, if there is a better location for the tests, I'm open to moving them around too.

Due to #1568, we now propagate pause and resume to the response content stream, rather than the response stream. However, when pause is called before the response arrives, the pause is still being applied to the response object directly. Fix this by applying it to the response content stream in both cases. This avoids the issue that if pause is called on a gzip request before the response arrives, it pauses the response then resumes the response content, meaning the response can not be resumed.

Also add tests of the pause/resume behavior for both the gzip and non-gzip case both before and after the response has arrived.

This commit also makes the ancillary change that resume is now called unconditionally (when defined) in Redirect, since we always want to dump the response data (and it was previously called unconditionally in onRequestResponse).

Due to request#1568, we now propagate pause and resume to the response content
stream, rather than the response stream.  However, when pause is called
before the response arrives, the pause is still being applied to the
response object directly.  Fix this by applying it to the response
content stream in both cases.  This avoids the issue that if pause is
called on a gzip request before the response arrives, it pauses the
response then resumes the response content, meaning the response can not
be resumed.

Also add tests of the pause/resume behavior for both the gzip and
non-gzip case both before and after the response has arrived.

This commit also makes the ancillary change that resume is now called
unconditionally (when defined) in Redirect, since we always want to
dump the response data (and it was previously called unconditionally in
onRequestResponse).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@simov

simov commented May 11, 2015

Copy link
Copy Markdown
Member

LGTM 👍

simov added a commit that referenced this pull request May 11, 2015
Fix pause before response arrives
@simov
simov merged commit 880d9a0 into request:master May 11, 2015
@kevinoid

Copy link
Copy Markdown
Contributor Author

Great! Thanks again @simov!

sabaoongfx pushed a commit to sabaoongfx/request-modern that referenced this pull request Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants