A WebJames question
Dave Higton (1515) 3526 posts |
Is it possible to access the client’s HTTP header lines from BASIC in the site’s cgi-bin directory? If so, how? I want to access the user agent string. I can see how to do it from CGI script files, or SHTML, but I can’t see how to do it from BASIC. |
John Sandgrounder (1650) 574 posts |
The BASIC runs as a CGI script. So, the same logic should apply. It is too complicated to explain here. But, hhere is an example script in the cgi-lib. Look in the cgi_lib for CGI_HeaderInMemory% and then PRINT $CGI_HeaderInMemory% you will get something like |
Dave Higton (1515) 3526 posts |
John, thank you for pointing me in the right direction – I’d never have found it otherwise. The proper way appears to be to call FNCGI_ReadRequestLine(tag$, next%) with tag$ as the request including the terminating colon (in my case, "User-Agent:") and next% initially 0, until either the function returns a non-empty string (in which case, it’s the value of the header you’ve requested) or next% is -1 (in which case the desired header hasn’t been found). You’ve helped me; I hope this may help someone else! |