fix(gateway)!: no duplicate payload during subdomain redirects #9913
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.
Rationale
Based on ipfs/boxo#326 (comment):
We have made significant progress on writing specifications of the Path Gateway to Subdomain Gateway. It is time to remove hacks and unidiomatic HTTP behavior from Kubo's Gateway.
Previously, when performing redirects from Path gw to Subdomain gw, the response body would include the data. However, we have decided to discontinue this behavior for multiple reasons:
Firstly, it was identified that this approach was a hack and not a recommended practice, antipattern when looking at HTTP Semantics. To ensure consistency and discourage others from implementing this non-standard behavior, we have removed it from the gateway-conformance requirements too (fix: remove body check for subdomain redirection gateway-conformance#65).
Secondly,
ipfs.io
did not become a Subdomain Gateway. We've decoded to use a separate domain name for that,dweb.link
. Thus, the redirect body hack was never deployed toipfs.io
.Additionally, including the CID data in the response body was found to be inefficient and could lead to increased bandwidth usage and latency for clients unable to drop the connection after receiving the
Location
header. In such cases, client would receive data twice.If any automation or process relies on the old behavior, the response body will now include a text/html message, whichwill inform the user about the redirect and provide the URL of the new location. This change makes it easier for legacy users to identify and troubleshoot any issues that may arise due to the modified behavior.
Overall, these changes aim to improve the performance, consistency, and maintainability of the Path Gateway to Subdomain Gateway redirects, while providing clear information to users in case of any unexpected behavior.