fivem icon indicating copy to clipboard operation
fivem copied to clipboard

tweak(server/http): provide error response headers

Open D4isDAVID opened this issue 1 year ago • 1 comments

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

  • [x] Code compiles and has been tested successfully.
  • [x] Code explains itself well and/or is documented.
  • [x] My commit message explains what the changes do and what they are for.
  • [x] No extra compilation warnings are added by these changes.

D4isDAVID avatar Sep 21 '24 20:09 D4isDAVID

Any ETA for review of this PR ?

Roms1383 avatar May 12 '25 02:05 Roms1383

Any updates on a review on this? Most of the PR is moving some of the code outside an if statement, and the rest is minimal additions.

D4isDAVID avatar Jul 25 '25 19:07 D4isDAVID