This repository has been archived by the owner on Apr 26, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a mild redesign of how client requests are forwarded in the .NET proxy. It provides a chance for request headers to be set through the new "copyRequestHeaders" function. This creates some flexibility for future modifications as well.
By copying headers from the client's request to the proxy's request, the proxy can now forward headers such as User-Agent, Cookie, Range, and so forth, which were formerly dropped by the proxy.
My personal need for this was to be able to properly handle PDF files. Clients such as Chrome will try to make partial range queries of PDF files if allowed by the server. Because we were copying response headers but not request headers, this created an issue where Chrome was told that it MAY make partial range requests, when in fact the requested range would get dropped. I confirmed that the .NET proxy is now able to handle partial byte ranges.
Handling partial content also meant that the proxy needs to be able to return a status code 206 (Partial Content). To allow for this, I modified the fetchAndPassBackToClient function to copy the server's response code as the proxy's response code.