简体   繁体   中英

Unity 2017.3.0f3 post data not being sent to LAMP server

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: 在此处输入图片说明

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)

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM