HTTP/1.1 400 Bad Request

Scripting questions, discussions, etc
4 posts Page 1 of 1
Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Nov 26, 2019 4:25 pm
This has worked for me in the past and copy/paste to a new app now it does not work. gameone.php exists on the server, just simple code to write to a text file

%data = "code="@$TCPCode @ "&sname="@%sname @ "&wmis="@%mission;

%httpCmd="POST /game/gameone.php HTTP/1.1\nHost: www.myweb.com:80\nUser-Agent: Torque/1.0 \nAccept: */*\nContent-Length: "@ strlen(%data) @"\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\n\n" @ %data;

%this.send(%httpCmd @ " \r\n");


function TCPObj::onLine(%this, %line)
{
echo("TCP LINE "@%line); // returns HTTP/1.1 400 Bad Request
}

Anyone know if things have changed since 1.5.2 ?
Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Wed Dec 04, 2019 5:37 pm
Bump ... any ideas on this ?
I have a good system for messaging game activity if I can get this working and willing to share.....
Bloodknight
Posts: 305
Joined: Tue Feb 03, 2015 8:58 pm
by Bloodknight » Thu Dec 05, 2019 11:24 pm
have you tried using something like postman to validate your query?

difficult to analyse without seeing actual data vs collections of variables that could contain anything.
Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Fri Dec 06, 2019 1:10 am
What data would you like to see? I am just sending player name and mission number so
1 bob 2 = tcpcode name mission

here is the php. I have been using this for years and just this version I get a bad request

<!DOCTYPE html>
<html lang="en">
<HEAD>
</HEAD>
<BODY>
<?php

$code = $_POST["code"]; // $tcpCode ACTION CALLED BY USER

echo("CODE RECEIVED ".$code);
switch($code)
{
case 1:
updateFile();
break;
}
function updateFile()
{
$ip = $_SERVER['REMOTE_ADDR']; // THIS IP SENT MESSAGE
$name = $_POST["sname"];
$mis = $_POST["wmis"];
$date = date("Y-m-d");
$tab = "\t";
$nl = "\n";
$ipfile = "marsonetrack.txt";
$file = fopen($ipfile, "a");
fwrite($file,$date.$tab.$ip.$tab.$name.$tab.$mis.$nl);
fclose($file);
echo("ok");
}
?>
</BODY>
</HTML>
4 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests