How to get the headers of the requesting client?

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
TorstenHolmer
Posts: 57
Joined: Mon Oct 28, 2013 1:23 pm
Location: Dresden, Germany

How to get the headers of the requesting client?

Post by TorstenHolmer » Fri Sep 02, 2022 9:11 am

Hi,

in PHP there is a command getallheaders(), which allows to see the request headers of the client.
I couldn't find a similar command in LC server. Is there something similar or how could I get these client information?

Cheers,
Torsten

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to get the headers of the requesting client?

Post by jacque » Fri Sep 02, 2022 5:43 pm

I'm not sure if these are what you want but look at:
libURLLastHTTPHeaders
libURLLastRRHeaders
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Ralf Bitter
Posts: 21
Joined: Mon Aug 26, 2013 6:49 pm

Re: How to get the headers of the requesting client?

Post by Ralf Bitter » Fri Sep 02, 2022 6:05 pm

Check out the array variable "$_SERVER" in the dictionary.
Ralf

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 133
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: How to get the headers of the requesting client?

Post by bobcole » Sat Sep 03, 2022 6:17 pm

Torsten:
Take a look at this posting on the forum:
https://forums.livecode.com/viewtopic.p ... 88#p217208
From that posting:
Open the LiveCode dictionary and look for $_SERVER.
I have a file on my server (at on-rev LiveCode Hosting) that loops through the $_SERVER array and returns each line.
You can try it out here: https://morrevbon.com/listVars.lc
I think what you want is in the line that starts with: "HTTP_ACCEPT"
Let us know if this helps.
Bob

TorstenHolmer
Posts: 57
Joined: Mon Oct 28, 2013 1:23 pm
Location: Dresden, Germany

Re: How to get the headers of the requesting client?

Post by TorstenHolmer » Sat Sep 03, 2022 8:27 pm

Hi Bob and Ralf,

the solution is $_SERVER, BUT the dictionary is not complete, that's why I haven't found the solution. The server keys with HTPP_* were not mentionied in the dictionary!

Here is the code that is somehow similar from Bob's code to show all $_SERVER[*] keys.

Cheers,
Torsten

Code: Select all

<?lc
put "<table>" & cr
repeat for each key tKey in $_SERVER
	put "<tr><td><b>" & tKey & "</b></td>"  & "<td>" & $_SERVER[tkey] & "</td><tr>" & cr
end repeat
put "</table>" & cr
?>

TorstenHolmer
Posts: 57
Joined: Mon Oct 28, 2013 1:23 pm
Location: Dresden, Germany

Re: How to get the headers of the requesting client?

Post by TorstenHolmer » Sun Sep 04, 2022 9:38 am

In order to complete the answer of my question by myself:

HTTP_ACCEPT_LANGUAGE
HTTP_ACCEPT_ENCODING
HTTP_USER_AGENT
HTTP_ACCEPT

are the header values I was looking for.

Thanks to all for the help!
Torsten

Post Reply

Return to “CGIs and the Server”