Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to get llHTTPRequest Headers...

Just Dinkin
Registered User
Join date: 14 Apr 2006
Posts: 9
05-24-2006 16:11
I am wondering how I can extract the llHTTPRequest headers with php?

Its says in the wiki that "X-SecondLife-Object-Name" and "X-SecondLife-Object-Key" are sent along with the headers up to the webpage when you request llHTTPRequest to load a page. Does anyone have any idea?

Any help would be very much appreciated.

Just Dinkin
Lee Dimsum
Registered User
Join date: 22 Feb 2006
Posts: 118
05-24-2006 16:17
I'm using:
CODE

<?
$headers = apache_request_headers();
if( $headers['X-SecondLife-Owner-Key'] != "mykey" )
{
die();
}
?>
yetihehe Saarinen
Registered beast
Join date: 19 Feb 2006
Posts: 40
05-25-2006 04:57
CODE

<?php

print_r($_SERVER);

?>

This will show you everything you want to know.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
05-25-2006 10:48
From: yetihehe Saarinen
CODE

<?php

print_r($_SERVER);

?>

This will show you everything you want to know.


...and spew it back to your object which will make it hard to output ;)

Try things like $_SERVER['HTTP_X_SECONDLIFE_REGION'].
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
05-25-2006 15:36
the only way to capture the full result of print_r($_SERVER); is to store it on the server. the SLS string buffer fills up around [REQUEST_URI]. I don't know about any one else, but I've been having some interesting results with http_response. Like events coming out of order.



BTW has any one figured out a successful way to determine that a message is being sent from SL?
Right now I'm thinking of using:
CODE
if( $headers['REMOTE_ADDR'] == '72.5.12.173' ){}
Nick Shatner
Isn't a game
Join date: 11 Jul 2005
Posts: 39
05-25-2006 16:44
Each sim has a different IP I believe - it'd be better to resolve the ip to the hostname then check a match for *.lindenlab.com
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
05-26-2006 10:53
No, that'd open you up for spoofing. There's nothing to stop me from having my ISP change my IP reverse-lookup entry to be "haxed.lindenlab.com" and then sending an HTTP request to your server and tricking it. I've had two ISPs so far that'd support changing the reverse-lookup entry, and my current one lets me do it automatically. It'd be better to figure out a list or range of IPs that Linden Lab owns and compare that. To build the list, use IP WHOIS or post in the hotline.

If you really truly want to be secure, send a secret password with the request. And if even sending the password in the clear isn't secure enough, try encrypting the current time down to one-minute precision with the password in LSL, and make sure your server and linden lab's are synched to within a minute.
Fractal Mandala
Registered User
Join date: 15 Dec 2003
Posts: 60
05-26-2006 16:46
From: Lex Neva
No, that'd open you up for spoofing. There's nothing to stop me from having my ISP change my IP reverse-lookup entry to be "haxed.lindenlab.com" and then sending an HTTP request to your server and tricking it. I've had two ISPs so far that'd support changing the reverse-lookup entry, and my current one lets me do it automatically. It'd be better to figure out a list or range of IPs that Linden Lab owns and compare that. To build the list, use IP WHOIS or post in the hotline.


You could do a reverse lookup, then do a lookup on the resulting name and make sure it matches the original address.
yetihehe Saarinen
Registered beast
Join date: 19 Feb 2006
Posts: 40
05-28-2006 04:15
You're right, i used it with output to file. So now only list of keys, it should be enough.
CODE

<?php
echo implode(",",array_keys($_SERVER));
?>
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
06-02-2006 21:11
From: yetihehe Saarinen
You're right, i used it with output to file. So now only list of keys, it should be enough.
CODE

<?php
echo implode(",",array_keys($_SERVER));
?>
I tried this and I got "PMAuthDigestEnableQueryStringHack,HTTP_USER_AGENT,HTTP_HOST,HTTP_ACCEPT,HTTP_ACCEPT_LANGUAGE,HTTP_ACCEPT_CHARSET,HTTP_ACCEPT_ENCODING,HTTP_CACHE_CONTROL,HTTP_CONNECTION,HTTP_TE,PATH,SystemRoot,COMSPEC,PATHEXT,WINDIR,SERVER_SIGNATURE,SERVER_SOFTWARE,SERVER_NAME,SERVER_ADDR,SERVER_PORT,REMOTE_ADDR,DOCUMENT_ROOT,SERVER_ADMIN,SCRIPT_FILENAME,REMOTE_PORT,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,QUERY_STRING,REQUEST_URI,SCRIPT_NAME,PHP_SELF,REQUEST_TIME,argv,argc
" as a result.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
06-02-2006 21:52
CODE

//GET HEADERS FROM INCOMING HTTP SECONDLIFE REQUEST
$headers = apache_request_headers();

foreach ($headers as $header => $value) {
$headername[$i] = $header;
$fixedheader[$i] = $value;
$i++;
}


I had a problem with some of the other methods given above by other people.

This will dump all of the headers into a normal array. There are 22 headers that are returned. One thing to notice, the order that the headers are listed on the wiki are *not* the order they are sent in from SL. I'm sorry I don't have a complete list, however if you do

CODE

for($i=0;$i<count($headername);$i++){
echo $headername[$i].": ".$fixedheader[$].'\n';
}


then it will echo back the headers and the values together.
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
06-03-2006 06:16
CODE
<?
$headers = apache_request_headers();

foreach ($headers as $header => $value) {
$headername[$i] = $header;
$fixedheader[$i] = $value;
$i++;
}
for($i=0;$i<count($headername);$i++){
echo $headername[$i].": ".$fixedheader[$].'\n';
}
?>

When I debug the above I get an error message, "Parse error: unexpected '[', expecting T_VARIABLE or '$' in line 10" the line inside the second loop: "echo $headername[$i].": ".$fixedheader[$].'\n';".
My untrained eye wants to put an "i" in "fixedheader[$]" but that doesn't work either.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Rodrick Harrington
Registered User
Join date: 9 Jul 2005
Posts: 150
06-03-2006 10:02
CODE
echo $headername[$i].": ".$fixedheader[$i].'\n';


looks like it should be correct with the added i, like you said.
_____________________
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
06-03-2006 14:00
From: Lex Neva
...and spew it back to your object which will make it hard to output ;)

Try things like $_SERVER['HTTP_X_SECONDLIFE_REGION'].


In the wiki the names are shown in title case, with hyphens instead of uppercase, with underscores, is there a reason for that?

Examples, cut and pasted from wiki: X-SecondLife-Region X-SecondLife-Shard X-SecondLife-Local-Position
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
LosAltos Commerce
Registered User
Join date: 12 Jun 2006
Posts: 1
Found it
06-13-2006 12:49
I don't know if you all found out already, but this is what I could find out:


$_SERVER["HTTP_X_SECONDLIFE_OBJECT_KEY"] // object key
$_SERVER["HTTP_X_SECONDLIFE_SHARD"] // production or test
$_SERVER["HTTP_X_SECONDLIFE_OBJECT_NAME"] // object name
$_SERVER["HTTP_USER_AGENT"] // SL Viewer version
Zero Linden
Linden Lab Employee
Join date: 18 Oct 2005
Posts: 22
06-13-2006 22:00
Some notes:

As per the HTTP standard, headers are not order independent. Do not rely on the order these headers may come in.

Also, as per the standard, header names are not case sensitive, and traditionally a combination of alpha-numerics and hyphens. Don't depend on the case of the headers.

Between Apache and PHP, one place the headers end up is PHP's $_SERVER variable. It seems to take all the HTTP headers, upper case them, substitute underscores for hyphens, prepend "HTTP_" to them, and then use that as keys to store values. Hence, when llHTTPRequest() passes, say,
CODE
X-SecondLife-Object-Name: Bob
as a header, it is accessible in PHP as:
CODE
$_SERVER["HTTP_X_SECONDLIFE_OBJET_NAME"]


The headers can also be accessed in PHP via the getallheaders(), apache_request_headers(), and (in PHP 5) get_headers() functions. However, these functions appear to retain the case of the header name, and so must be used carefully.
Woopsy Dazy
Registered User
Join date: 12 Nov 2006
Posts: 173
02-03-2007 04:41
Adding some php-code here so I (we) can find it again. Some things has been lost in the new wiki. This is a basic sample on how to "manually" retreive all headers:

$SL_Shard = $_SERVER["HTTP_X_SECONDLIFE_SHARD"];
$SL_Object_Name = $_SERVER["HTTP_X_SECONDLIFE_OBJECT_NAME"];
$SL_Object_Key = $_SERVER["HTTP_X_SECONDLIFE_OBJECT_KEY"];
$SL_Region = $_SERVER["HTTP_X_SECONDLIFE_REGION"];
$SL_Local_Position = $_SERVER["HTTP_X_SECONDLIFE_LOCAL_POSITION"];
$SL_Local_Rotation = $_SERVER["HTTP_X_SECONDLIFE_LOCAL_ROTATION"];
$SL_Local_Velocity = $_SERVER["HTTP_X_SECONDLIFE_LOCAL_VELOCITY"];
$SL_Owner_Name = $_SERVER["HTTP_X_SECONDLIFE_OWNER_NAME"];
$SL_Owner_Key = $_SERVER["HTTP_X_SECONDLIFE_OWNER_KEY"];

echo "\n";
echo "---------------------\n";
echo "SL_Shard: ".$SL_Shard."\n";
echo "SL_Object_Name: ".$SL_Object_Name."\n";
echo "SL_Object_Key: ".$SL_Object_Key."\n";
echo "SL_Region: ".$SL_Region."\n";
echo "SL_Local_Position: ".$SL_Local_Position."\n";
echo "SL_Local_Rotation: ".$SL_Local_Rotation."\n";
echo "SL_Local_Velocity: ".$SL_Local_Velocity."\n";
echo "SL_Owner_Name: ".$SL_Owner_Name."\n";
echo "SL_Owner_Key: ".$SL_Owner_Key."\n";
echo "---------------------\n";

And here's a sample result of the web-page output (body) in SL:

[4:36] HTTP Headers Test:
---------------------
SL_Shard: Production
SL_Object_Name: HTTP Headers Test
SL_Object_Key: 6be56336-b249-16f2-fd39-8a6530bba8bc
SL_Region: Natoma (256512, 256256)
SL_Local_Position: (47.261887, 73.185715, 25.214600)
SL_Local_Rotation: (0.000000, 0.000000, 0.000000, 1.000000)
SL_Local_Velocity: (0.000000, 0.000000, 0.000000)
SL_Owner_Name: Woopsy Dazy
SL_Owner_Key: 179608ce-50f8-6a0f-00e1-083e2f8193ee
---------------------