PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

[FIXED] Unity 2017.3.0f3 post data not being sent to LAMP server

 February 28, 2022     apache, cpanel, lamp, php, unity3d     No comments   

Issue

It looks like my cpanel/WHM server has probably (though I am not sure what is the cause) been set with some security settings, where PHP is not receiving form data posted from other domains / computers / devices...

I've tested null $_REQUEST (and also $_POST - just in case) dump for post data where the origin comes to the server from another device.

  • I have also tried CORS setting all in PHP header("access-control-allow-origin: *");

  • I have also set in .htaccess in both the parent directory and the directory of the php Header set Access-Control-Allow-Origin "*"

  • as a sanity check, i've tried it with barebones php, no cookies. this will only print if the script sending post variables is from the same server, but will not work if it's elsewhere <?php print_r($_REQUEST)

Header response from client: enter image description here

Is there a way not to stop but to allow post data from any source?

(Also for a sanity check, tested client script from remote device posting to server to work on https://posttestserver.com/ - so it is definitely PHP server not accepting post fields)


Solution

Apparently, in Unity 2017.3.0f3 request.chunkedTransfer (from request = new UnityWebRequest) is set to true, setting it to false allows for the php://input stream variables to go through.

However, depending on how you are encoding the form, $_REQUEST and $_POST are still null arrays until request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); is added...

request.chunkedTransfer = false; // just this might work if you are using WWWForm
request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");


Answered By - ina
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing