openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
753 stars 365 forks source link

HTTPRequest won't return data if a web page returns an error status code (likely only on native). #1699

Closed SiideCode closed 1 year ago

SiideCode commented 1 year ago

I have no clue if it applies to any non-native targets, because I only compile with HXCPP.

Some APIs and websites return useful information alongside with an error status code, like additional error data, or a custom 4XX web page, yet Lime always interprets it as "The page is empty", so if the page you've requested returns an error, HTTPRequest will simply return promise.error and fill out everything that is not the web page data (status code, headers, etc.). (Doesn't seem to be an issue with haxe.Http though, as it still returns data even after it gets a 4XX range HTTP status code).

joshtynjala commented 1 year ago

I can see that Flash/AIR sets the data property of URLLoader to the page contents for a 404 error, even though it dispatches IOErrorEvent.IO_ERROR and not Event.COMPLETE. If we want OpenFL to match Flash/AIR, Lime needs to return the page contents with its HTTP errors too.

This seems to affect all targets when using Lime's HTTPRequest directly.