tweak(server/http): provide error response headers #2804
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.
Goal of this PR
In the source code, an HTTP request failure is both failure to connect, but also response codes such as 4xx or 5xx. In both cases, response headers are not provided to scripts.
The problem is that when HTTP servers respond with an error code such as 4xx or 5xx, they may also provide response headers which may contain valuable information - such as the Discord API providing rate limit information when getting rate limited.
The goal is to provide those response headers when requests fail.
How is this PR achieving the goal
Always creates the response data, not only when the request is successful, and passes it to the callback event also when the request has failed.
Seeing as this may be constituted as a breaking change, I passed it as a new callback parameter instead of the existing
headers
parameter.This PR applies to the following area(s)
Server, ScRT: Lua
Successfully tested on
Platforms: Windows
Checklist