HTML5 HTTPRequest: unexpected characters at end of POST string

I get unexpected characters at the end of my json file when preforming a HttpRequest operation while running in HTML 5. No problems while running in desktop builds. (UE 4.7.4 - binary, emscripten 1.29.0)

TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();

HttpRequest->SetVerb(TEXT("POST"));
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
HttpRequest->SetURL("/*url*/");
HttpRequest->SetContentAsString(TEXT("[ \"jsonString1\", \"jsonString2\" ]"));

HttpRequest->OnProcessRequestComplete().BindUObject(this, &UConnection::RequestComplete);

HttpRequest->ProcessRequest();

Result in Database

Hey

In order to assist you better, it would be helpful if we had the crash uploaded to your next reply. Please save these as .txt files. I’d also like to know whether or not you’re attempting to run your HTML5 project within a web browser? If so, which one? Please provide me with the version as well.

Looking forward to hearing back from you.

Hi ,

Don’t experience any crashes, no abnormalities in desktop builds either.
It’s only when running the project in a browser.

So

  1. I post a string (eg. “test”) with the code above to a given url

  2. The raw data that has been posted is read by a php script at that location using this php line:

    $raw_data = file_get_contents(“php://input”); //result should be ‘test’

  3. The php script then stores this data (‘test’) in a database table

  4. As shown in the screenshort above I notice sporadic random trailing characters at the end of the posted string in my table. Sometimes its fine: ‘test’, sometimes it’s not: ‘testp’, ‘testo’, ‘testƒº¬’, …

This only occurs when posted from within a browser and the occurrence seems to be random (the first three lines in my screenshot were posted using the desktop build and they are always fine)

I’ve tested several browsers (Firefox, , Chrome, Safari) both on PC and Mac. They all seem to be providing me with the sporadic random trailing characters.

Now

I do have a work around for the time being…

I’ve put a special character at the end of each string and, in my php script, I go ahead and delete all things and then some behind that character. So in the end it’s pretty again :slight_smile:

Hey

I’ve spoken with our HTML5 developers and they noticed the issue with what you’re experiencing. Therefore, I have submitted a bug report. If you need to reference this report in the future, please refer to: UE-13431

Thank you!

Ok,

Thanks

Hey

I heard back from the developers. It looks like the issue reported should be fixed with https://github.com/EpicGames/UnrealEngine/commit/3493522c66c5e45ad98f53042dca1313ac17dc90 - - if you’re using GitHub distribution, please selectively merge this check-in…otherwise you’ll need to wait for the releases of 4.8.

Thanks!

Great! Thanks