Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent potential issues and crashes with HTTP requests. #551

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void function NSHandleSuccessfulHttpRequest( int handle, int statusCode, string
response.statusCode = statusCode
response.body = body
response.rawHeaders = headers
response.headers = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK @Erlite has become inactive on this account. Maybe @Zanieon could take this PR over?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't worked with anything on the HTTP requests of Northstar yet, judging by those functions code i'm uncertain how their logic functions, especially if there's integration at Launcher side.


// Parse the raw headers into key -> values
array<string> values = split( headers, "\n" )
Expand Down Expand Up @@ -156,6 +157,13 @@ void function NSHandleFailedHttpRequest( int handle, int errorCode, string error
*/
bool function NSHttpRequest( HttpRequest requestParameters, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
{
#if CLIENT
if ( IsPlayingDemo() )
{
return false
}
#endif

int handle = NS_InternalMakeHttpRequest( requestParameters.method, requestParameters.url, requestParameters.headers,
requestParameters.queryParameters, requestParameters.contentType, requestParameters.body, requestParameters.timeout, requestParameters.userAgent )

Expand All @@ -182,6 +190,13 @@ bool function NSHttpRequest( HttpRequest requestParameters, void functionref( Ht
*/
bool function NSHttpGet( string url, table< string, array< string > > queryParameters = {}, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
{
#if CLIENT
if ( IsPlayingDemo() )
{
return false
}
#endif

HttpRequest request
request.method = HttpRequestMethod.GET
request.url = url
Expand All @@ -201,6 +216,13 @@ bool function NSHttpGet( string url, table< string, array< string > > queryParam
*/
bool function NSHttpPostQuery( string url, table< string, array< string > > queryParameters, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
{
#if CLIENT
if ( IsPlayingDemo() )
{
return false
}
#endif

HttpRequest request
request.method = HttpRequestMethod.POST
request.url = url
Expand All @@ -220,6 +242,13 @@ bool function NSHttpPostQuery( string url, table< string, array< string > > quer
*/
bool function NSHttpPostBody( string url, string body, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
{
#if CLIENT
if ( IsPlayingDemo() )
{
return false
}
#endif

HttpRequest request
request.method = HttpRequestMethod.POST
request.url = url
Expand Down
Loading