pike.git / lib / modules / Protocols.pmod / EngineIO.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:57:   #define PDT(X ...) 0   #define PT(X ...) (X)   #endif      #define SIDBYTES 16   #define TIMEBYTES 6      //! Global options for all EngineIO instances.   //!   //! @seealso - //! @[Socket.create()] + //! @[Socket.create()], @[Gz.compress()]   final mapping options = ([    "pingTimeout": 64*1000, // Safe for NAT    "pingInterval": 29*1000, // Allows for jitter -  "allowUpgrades": 1, -  "compressionLevel": 1, // gzip -  "compressionThreshold": 256 // Compress when size>= + #if constant(Gz.deflate) +  "compressionLevel": 1, +  "compressionStrategy": Gz.DEFAULT_STRATEGY, +  "compressionThreshold": 256, // Compress when size>= +  "compressionWindowSize": 15, // LZ77 window 2^x (8..15) + #endif +  "allowUpgrades": 1   ]);      //! Engine.IO protocol version.   constant protocol = 3; // EIO Protocol version      private enum {    // 0 1 2 3 4 5 6    BASE64='b', OPEN='0', CLOSE, PING, PONG, MESSAGE, UPGRADE, NOOP,    SENDQEMPTY, FORCECLOSE   };
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:143:       //! Contains the last request seen on this connection.    //! Can be used to obtain cookies etc.    final Protocols.WebSocket.Request request;       //! The unique session identifier (in the Engine.IO docs referred    //! to as simply: id).    final string sid;       private mixed id; // This is the callback parameter -  protected mapping options; +  mapping options;    private Stdio.Buffer ci = Stdio.Buffer();    private function(mixed, string|Stdio.Buffer:void) read_cb;    private function(mixed:void) close_cb;    private Thread.Queue sendq = Thread.Queue();    private ADT.Queue recvq = ADT.Queue();    private string curtransport;    private Transport conn;    private Transport upgtransport;    private enum {RUNNING = 0, PAUSED, SCLOSING, RCLOSING};    private int state = RUNNING;
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:199:    class Polling {    inherit Transport:t;       private int forceascii;    final protected Stdio.Buffer c = Stdio.Buffer();    final protected Stdio.Buffer ci = Stdio.Buffer();    final protected Protocols.WebSocket.Request req;    private mapping headers = ([]);    private Thread.Mutex getreq = Thread.Mutex();    private Thread.Mutex exclpost = Thread.Mutex(); -  #if constant(Gz.File) +  #if constant(Gz.deflate)    private Gz.File gzfile;    #endif    protected string noop;       protected void getbody(Protocols.WebSocket.Request _req);    protected void wrapfinish(Protocols.WebSocket.Request req, string body);       protected void respfinish(Protocols.WebSocket.Request req,    void|string body, void|string mimetype) {    mapping|string comprheads;    if (!body)    body = noop; -  #if constant(Gz.File) +  #if constant(Gz.deflate)    if (gzfile && sizeof(body) >= options->compressionThreshold    && (comprheads = req.request_headers["accept-encoding"])    && acceptgzip.match(comprheads)) {    Stdio.FakeFile f = Stdio.FakeFile("", "wb");    gzfile.open(f, "wb"); -  +  gzfile.setparams(options->compressionLevel, +  options->compressionStrategy, options->compressionWindowSize);    gzfile.write(body);    gzfile.close();    comprheads = headers;    if (sizeof(body)>f.stat().size) {    body = (string)f;    comprheads += (["Content-Encoding":"gzip"]);    }    } else    #endif    comprheads = headers;    req.response_and_finish(([    "data":body,    "type":mimetype||"text/plain;charset=UTF-8",    "extra_heads":comprheads]));    }       protected void create(Protocols.WebSocket.Request _req) {    noop = sprintf("1:%c", NOOP);    forceascii = !zero_type(_req.variables->b64);    ci->set_error_mode(1); -  int clevel; -  #if constant(Gz.File) -  if (clevel = options->compressionLevel) -  (gzfile = Gz.File()).setparams(clevel, Gz.DEFAULT_STRATEGY); +  #if constant(Gz.deflate) +  if (options->compressionLevel) +  gzfile = Gz.File();    #endif    t::create(_req);    if (_req.request_headers.origin) {    headers["Access-Control-Allow-Credentials"] = "true";    headers["Access-Control-Allow-Origin"] = _req.request_headers.origin;    } else    headers["Access-Control-Allow-Origin"] = "*";    // prevent XSS warnings on IE    string ua = _req.request_headers["user-agent"];    if (ua && xxsua.match(ua))