Roxen.git / server / modules / misc / websocket.pike

version» Context lines:

Roxen.git/server/modules/misc/websocket.pike:55:   {    string raw_key = "";    catch {    raw_key = MIME.decode_base64(id->request_headers["sec-websocket-key"]);    };    return sizeof(raw_key) >= 16;   }      // Operation:   // - // * For syntactically valid WebSocket requests, the - // method field in the RequestID is set to "WebSocketOpen", + // * For syntactically valid WebSocket requests, the method + // field in the RequestID is set to Roxen.WEBSOCKET_OPEN_METHOD,   // the default error_code set to HTTP_BAD and zero returned.   //   // * For requests that don't seem to be WebSocket requests   // nothing is done, and zero is returned.   //   // * For requests that are upgrade requests to other than   // websockets, the default error_code is set to HTTP_BAD,   // and zero returned.   //   // * For other invalid requests an appropriate HTTP_BAD   // error status is returned.   //   // This means that modules implementing support for WebSockets - // need to check for the method "WebSocketOpen", and then - // return Roxen.upgrade_to_websocket() if appropriate. + // need to check for the method Roxen.WEBSOCKET_OPEN_METHOD, + // and then return Roxen.upgrade_to_websocket() if appropriate.      mapping(string:mixed)|int(-1..0) first_try(RequestID id)   {    TRACE_ENTER("Checking if this is a valid websocket request...", this);    if (id->misc->internal_get) {    TRACE_LEAVE("No - internal request.");    return 0;    }       if (id->method != "GET") {
Roxen.git/server/modules/misc/websocket.pike:136:    if (!has_prefix(id->prot, "HTTP/") ||    (id->prot[sizeof("HTTP/")..] < "1.1")) {    // HTTP/1.1 or later required.    NOCACHE();    TRACE_LEAVE("No - not HTTP/1.1 or later.");    return 0;    }       TRACE_LEAVE("Yes.");    -  // NB: The mixed case in the method ensures that it can't be -  // set directly from the http request. -  id->method = "WebSocketOpen"; +  id->method = Roxen.WEBSOCKET_OPEN_METHOD;    id->misc->error_code = Protocols.HTTP.HTTP_BAD;       // Continue request processing.    return 0;   }