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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:194:    read_cb(FORCECLOSE);    }       final protected void sendqempty() {    if (!sendq.size())    read_cb(SENDQEMPTY);    }    }       class Polling { -  inherit Transport:t; +  inherit Transport;       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.deflate)    private Gz.File gzfile;
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:248:    }       protected void create(Protocols.WebSocket.Request _req) {    noop = sprintf("1:%c", NOOP);    forceascii = !zero_type(_req.variables->b64);    ci->set_error_mode(1);    #if constant(Gz.deflate)    if (_options->compressionLevel)    gzfile = Gz.File();    #endif -  t::create(_req); +  ::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))    headers["X-XSS-Protection"] = "0";    onrequest(_req);
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:389:    if (sizeof(c))    wrapfinish(myreq, c->read());    sendqempty();    } else    lock = 0;    }    }    }       class XHR { -  inherit Polling:p; +  inherit Polling;    constant forcebinary = 1;       final protected void getbody(Protocols.WebSocket.Request _req) {    ci->add(_req.body_raw);    }       final protected    void wrapfinish(Protocols.WebSocket.Request req, string body) {    respfinish(req, body, String.range(body)[1]==0xff    ? "application/octet-stream" : 0);    }    }       class JSONP { -  inherit Polling:p; +  inherit Polling;       private string head;       protected void create(Protocols.WebSocket.Request req) { -  p::create(req); +  ::create(req);    head = "___eio[" + (int)req.variables->j + "](";    noop = head+"\""+::noop+"\");";    }       final protected void getbody(Protocols.WebSocket.Request _req) {    string d;    if (d = _req.variables->d)    // Reverse-map some braindead escape mechanisms    ci->add(replace(d,({"\r\n","\\n"}),({"\r","\n"})));    }       final protected    void wrapfinish(Protocols.WebSocket.Request req, string body) {    c->add(head)->add(Standards.JSON.encode(body))->add(");");    respfinish(req, c->read());    }    }       class WebSocket { -  inherit Transport:t; +  inherit Transport;       private Protocols.WebSocket.Connection con;    private Stdio.Buffer bb = Stdio.Buffer();    private String.Buffer sb = String.Buffer();       final void close() {    if (con)    catch(con.close());    }       protected void create(Protocols.WebSocket.Request req,    Protocols.WebSocket.Connection _con) {    con = _con;    con.onmessage = recv;    con.onclose = ::close; -  t::create(req); +  ::create(req);    }       final void flush(void|int type, void|string|Stdio.Buffer msg) {    void sendit() {    con.send_text(sprintf("%c%s",type,stringp(msg) ? msg : msg->read()));    };    if (msg)    sendit();    else {    array tosend;