I wrote a web service using content-negotiation with ISAPI using Delphi XE4.
My code contains
ARequest.GetFieldByName('Accept-Language')
which outputs the correct value if I use a standalone server (Indy Bridge), but it is empty if I use an ISAPI DLL inside Apache.
Is there any way I can access this header field with ISAPI in Apache?
Since ISAPI is kind-of a successor to CGI, the 'default' HTTP headers get converted to CGI-style parameters, so you need to request HTTP_ACCEPT_LANGUAGE
using the extension control block's GetServerVariable
. Like so:
function GetVar(pecb: PEXTENSION_CONTROL_BLOCK; const key:AnsiString):AnsiString;
var
l:cardinal;
begin
l:=$10000;
SetLength(Result,l);
if not(pecb.GetServerVariable(pecb.ConnID,PAnsiChar(key),PAnsiChar(Result),l)) then
if GetLastError=ERROR_INVALID_INDEX then l:=1 else RaiseLastOSError;
SetLength(Result,l-1);
end;
//
GetVar(ecb,'HTTP_ACCEPT_LANGUAGE')