I have a file in php
where I receive data from an application in Unity,
all good until after validating the information I need to recover a STATUS
.
I'm using this way of setting the STATUS
in php
;
if(count(mysql_fetch_array(mysql_query($sqlSelectNombUser,$cone)))>1){
$result="no valido";
http_response_code(400);
}else{
$result="valido";
$rsInsertNew=mysql_query($sqlInsertNew,$cone);
http_response_code(200);
}
And to recover it from Unity I use;
public static int getResponseCode(WWW request)
{
int ret = 0;
if (request.responseHeaders == null)
{
Debug.LogError("no response headers.");
}
else
{
if (!request.responseHeaders.ContainsKey("STATUS"))
{
Debug.LogError("response headers has no STATUS.");
}
else
{
ret = parseResponseCode(request.responseHeaders["STATUS"]);
}
}
return ret;
}
public static int parseResponseCode(string statusLine)
{
int ret = 0;
string[] components = statusLine.Split(' ');
if (components.Length < 3)
{
Debug.LogError("invalid response status: " + statusLine);
}
else
{
if (!int.TryParse(components[1], out ret))
{
Debug.LogError("invalid response code: " + components[1]);
}
}
return ret;
}
The fact is that I can not change STATUS
since I always receive the 200, even having forced the failure directly in PHP
.
How could I change the STATUS
to recover it in Unity?