Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why does the engine crash when I POST data to a server?

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>()
 request->OnProcessRequestComplete().BindUObject(this, &UAClass::ReceivedAuth);

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. alt text

Here is what my data looks like that causes the engine to crash alt text

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?

Product Version: UE 4.18
enginedata.png (75.6 kB)
mydata.png (110.6 kB)
more ▼

asked Nov 18 '17 at 02:14 PM in C++ Programming

avatar image

36 9 16 17

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Turns out I had to set the Content-Type to application/json and that fixed the problem.

 request->SetHeader("Content-Type", "application/json");
more ▼

answered Nov 19 '17 at 01:02 AM

avatar image

36 9 16 17

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question