3
\$\begingroup\$

I am working on communications between my game and a cloud database. I'm working on the authentication part but when I try to pass data to the server in a POST the engine crashes. If I pass in a simple string like "username" it does not crash and I get an error response from the server as expected. But when I try to pass in a JSON string the engine crashes. Here is my code:

OnAuthCookieResponse = cookieResponseDelegate;
TSharedRef<IHttpRequest> request = FHttpModule::Get().CreateRequest();
FString url = NewObject<UURLBuilder>()
     ->Host(BASE_URL)
     ->Path(SESSION)
     ->Build();

request->SetURL(url);
request->SetVerb("POST");
request->SetContentAsString("{\"username\":xxxxxxxx}");
request->OnProcessRequestComplete().BindUObject(this, &UAClass::ReceivedAuth);
request->ProcessRequest();

The stack trace points me to line 559 in CurlHttp.cpp. IsURLEncoded() returns false which causes the check() to fail.

check(!GetHeader("Content-Type").IsEmpty() || IsURLEncoded(RequestPayload));

However when the engine passes data here, IsURLEncoded() returns true and the check() passes. Here is a sample of some data from the engine that passes. You can see it is a JSON string. enter image description here

Here is what my data looks like that causes the engine to crash enter image description here

You can see they are both JSON strings but mine causes the check to fail. I have also tried to completely URL encode the JSON string and the check still fails.

So why does this fail for me but passes when used by the engine?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

{ and } are not valid URL characters, so your JSON is not URLEncoded. I bet the engine is sending a content type of application/json, which then bypasses the Url-Encoding check.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .