CG/PL: обработка HTTP запросов

: Alexey Naidyonov <CGatePro_at_mx_ru>
: Tue 07 Nov 2006 - 12:04:36 MSK


, .

HTTP CG/PL ? :

1. HTTP "CG/PL Applications":

CG/PL Common URL Prefix: /cgpl
CG/PL Account URL Prefix: /cgpl

URL Task
acd/queuestate acd.ajaxui.getqueuestate acd/queuecmd acd.ajaxui.issuequeuecmd ~/conf/userlist personalconference.ajaxui.getuserlist ...

2. URL http://server/cgpl/acd/queuestate http://server/~username/cgpl/conf/userlist ,
(Vars().httpRequest). , ,
, , .

3. , , , / , CGP . ,
(Vars().httpRequest.body).

4. , , - , .

:
- , XIMSS. , , "" . ( -, "" ), XIMSS . , ( CGP XIMSS), . , , , , " ". , -- api .. .

entry main is
  req = Vars().httpRequest;
  query = TextToObject(req.body);
  if query != null and then IsDictionary(query) then     res = newDictionary();
    res.rc = 200;
    ...
    res.body = ObjectToString(queryResult);     res.header.("Content-Type") = "text/cgp-dictionary";     HTTPSendResponse(res);
  else
    res = newDictionary();
    res.rc = 500;
    res.body = "<HTML><BODY>Error parsing query</BODY></HTML>";     HTTPSendResponse(res);
  end if;
end entry;

entry main is
  req = Vars().httpRequest;
  confId = req.queryParam.("confId");
  if RemoteAuthentication() != null then     res = newDictionary();

    res.rc = 200;
    res.header.("Content-Type") = "text/html";
    res.header.("Transfer-Encoding") = "chunked";
    HTTPSendResponseHeaders(res);
    HTTPOpenStream();
    HTTPWrite("<HTML><BODY>");
    while ... loop
       ...
       HTTPWrite(....);

    end loop;
    HTTPWrite("</BODY></HTML>");
    HTTPCloseStream();
  else
    res = newDictionary();
    res.rc = 403;
    res.body = "<HTML><BODY>Access denied</BODY></HTML>";     HTTPSendResponse(res);
  end if;
end entry;

SY,
--
Alexey Naidyonov
ITooLabs Tue Nov 07 09:04:38 2006

hypermail 2.1.8 : Fri 24 Apr 2015 - 16:15:15 MSK