Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: avoid body without destroying request #49

Merged
merged 2 commits into from Sep 24, 2022
Merged

feat: avoid body without destroying request #49

merged 2 commits into from Sep 24, 2022

Conversation

Kikobeats
Copy link
Owner

@Kikobeats Kikobeats commented Sep 22, 2022

The current source code implementation is aborting response body after the first chunk is received:

req.on('response', res => {
    response = res
    response.once('data', () => req.cancel())
  })

This is a very tricky way to avoid resolving the request body, and it will cause some undesirable behavior since the request was aborted abruptly.

Instead, we can setup range header to request the minimal quantity of body bytes. Could be possible the server doesn't support range requests, so we need to enable retry.

Perform a HEAD request is discarded since most of the servers disallow them.

@Kikobeats Kikobeats changed the title fix: disable compression feat: partial content resolution Sep 23, 2022
@Kikobeats Kikobeats changed the title feat: partial content resolution feat: better body strategy Sep 23, 2022
@coveralls
Copy link

coveralls commented Sep 23, 2022

Pull Request Test Coverage Report for Build 3112749662

  • 18 of 18 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2337757094: 0.0%
Covered Lines: 63
Relevant Lines: 63

💛 - Coveralls

@Kikobeats Kikobeats changed the title feat: better body strategy feat: avoid body without destroying request Sep 23, 2022
@Kikobeats Kikobeats merged commit a4f9e4d into master Sep 24, 2022
@Kikobeats Kikobeats deleted the next branch September 24, 2022 10:43
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.

None yet

2 participants