Jump to content

HTTPRequest header missing


Gregory McLeod
 Share

You are about to reply to a thread that has been inactive for 3513 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am using an HTTPRequest from a prim script

   SERVER_REQ_ID = llHTTPRequest( SERVER_URL+"&id="+(string)id, [], "" );

I naively thought that all httprequests were accompanied by the Second_life Headers.

The one I am missing is X-SecondLife-Owner-Key this results in an php script error and the returned data is invalid.

Do you have to use one of the GET or POST methods to get SL to send the full headers?

 

If so I wonder how this used to work, as it did.

Link to comment
Share on other sites

To try to resolve what I think may be a misunderstanding between us Darkie I show the whole of the PHP script that is being called and the method of calling.

The method of calling

<q>

string  SERVER_URL  = "http://awebsite.com/folder1/folder2/manager.php?action=UPDATE";
key     SERVER_REQ_ID;
integer id;

id = -1;

request_server() {
    SERVER_REQ_ID = llHTTPRequest( SERVER_URL+"&id="+(string)id, [], "" );
}

other lines of code

</q>

the receiving website manager.php

<q>

<?php

include_once('bin/DBHandler.php');

$USE_APACHE_HEADERS = TRUE;
// switch to false if you need cgi methods
if ($USE_APACHE_HEADERS)
{
 $headers    = apache_request_headers();
 $objectgrid = $headers["X-SecondLife-Shard"];
 $objectname = $headers["X-SecondLife-Object-Name"];
 $objectkey  = $headers["X-SecondLife-Object-Key"];
 $objectpos  = $headers["X-SecondLife-Local-Position"];
 $ownerkey   = $headers["X-SecondLife-Owner-Key"];
 $ownername  = $headers["X-SecondLife-Owner-Name"];
 $regiondata = $headers["X-SecondLife-Region"];
 $regiontmp  = explode ("(",$regiondata); // cut cords off
 $regionpos  = explode (")",$regiontmp[1]); //
 $regionname = substr($regiontmp[0],0,-1); // cut last space from simname
} else {
 $db = $GLOBALS;
 $headers    = $db['HTTP_ENV_VARS'];
 $objectgrid = $headers["HTTP_X_SECONDLIFE_SHARD"];
 $objectname = $headers["HTTP_X_SECONDLIFE_OBJECT_NAME"];
 $objectkey  = $headers["HTTP_X_SECONDLIFE_OBJECT_KEY"];
 $ownerkey   = $headers["HTTP_X_SECONDLIFE_OWNER_KEY"];
 $objectpos  = $headers["HTTP_X_SECONDLIFE_LOCAL_POSITION"];
 $ownername  = $headers["HTTP_X_SECONDLIFE_OWNER_NAME"];
 $regiondata = $headers["HTTP_X_SECONDLIFE_REGION"];
 $regiontmp  = explode ("(",$regiondata);
 $regionpos  = explode (")",$regiontmp[1]);
 $regionname = substr($regiontmp[0],0,-1);
}

if(!isset($ownerkey)) {
 print "INVALID_ACCESS";; 
}

$db = new DBHandler();

function createSurl($reg, $p) {
 $p = str_replace ( "(" , "" , $p );
 $p = str_replace ( ")" , "" , $p );
 $c = split ( "," , $p);
 return "secondlife://$reg/$c[0]/$c[1]/$c[2]";
}

$action = $_GET['action'];
switch($action) {
 case "UPDATE":
  $id = $_GET['id'];
  if( is_numeric ($id) ) {
   if($id == -1) {
    $index = $db->getLastIndex() + 1;
    if($db->addField($index, $ownername, createSurl($regionname, $objectpos)))
     print "NEW,$index";
    else
     print "Database Error";
   }
   else if($id > 0) {
    if($db->isField($id)) {
     if($db->updateField($id, $ownername, createSurl($regionname, $objectpos)))
     {
      if($db->isFieldActive($id)) 
       print "ENABLE";
      else
       print "DISABLE";
     }
     else {
      print "DISABLE";
     }
    }
    else if($db->addField($id, $ownername, createSurl($regionname, $objectpos)))
     print "NEW,$index";
    else
     print "Database Error";
   }
  }
  else
   print "INVALID";
 break;
}

</q>

Note in this PHP script there is an incompatability between the code and the PHP version in the statement

<q>

function createSurl($reg, $p) {
...

 $c = split ( "," , $p);

...

</q>

which is what got me into this mess in the first place. I have fixed that by changing the split to a preg_split as in

$c = preg_split( '[(,)]' , $p );

The result that the prim receives from the request is

INVALID_ACCESSINVALID

which suggest to me that the $ownerkey is not being set.

Do you have any comments?

Link to comment
Share on other sites

This PHP script returns all headers.

<?php  foreach ($_SERVER as $key => $value) {    if (strpos($key, 'HTTP_') === 0) {      $chunks = explode('_', $key);      $header = '';      for ($i = 1; $y = sizeof($chunks) - 1, $i < $y; $i++) {        $header .= ucfirst(strtolower($chunks[$i])).'-';      }      $header .= ucfirst(strtolower($chunks[$i])).': '.$value;      echo $header.'<br>';    }  }?>

 You could check them with:

    http_response(key id, integer s, list data, string body) {        list b = llParseString2List(body, ["<br>"], []);        integer l;        do {            llOwnerSay(llList2String(b, l));        } while (++l < llGetListLength(b));    }

 Then you know if your owner key header is available or not.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3513 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...