mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
add WEBSOCKET_TIMEOUT
This commit is contained in:
parent
42f5cee169
commit
a642027039
|
@ -189,6 +189,7 @@ userver {
|
|||
#
|
||||
# CGI_TIMEOUT timeout for cgi execution
|
||||
# VIRTUAL_HOST flag to activate practice of maintaining more than one server on one machine, as differentiated by their apparent hostname
|
||||
# WEBSOCKET_TIMEOUT timeout for websocket request
|
||||
# DIGEST_AUTHENTICATION flag authentication method (yes = digest, no = basic)
|
||||
#
|
||||
# URI_PROTECTED_MASK mask (DOS regexp) of URI protected from prying eyes (that needs authentication)
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
class UHTTP;
|
||||
class USocket;
|
||||
class UCommand;
|
||||
class UHttpPlugIn;
|
||||
class UDataStorage;
|
||||
class UProxyPlugIn;
|
||||
class UWebSocketClient;
|
||||
|
@ -183,8 +184,8 @@ private:
|
|||
static uint32_t max_message_size;
|
||||
static URDBObjectHandler<UDataStorage*>* db;
|
||||
|
||||
static int status_code;
|
||||
static UString* rbuffer;
|
||||
static int status_code, timeoutMS; // the time-out value in milliseconds for client request
|
||||
static const char* upgrade_settings;
|
||||
static WebSocketFrameData control_frame;
|
||||
static WebSocketFrameData message_frame;
|
||||
|
@ -199,6 +200,7 @@ private:
|
|||
U_DISALLOW_COPY_AND_ASSIGN(UWebSocket)
|
||||
|
||||
friend class UHTTP;
|
||||
friend class UHttpPlugIn;
|
||||
friend class UProxyPlugIn;
|
||||
friend class UWebSocketClient;
|
||||
friend class UWebSocketPlugIn;
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
//
|
||||
// ============================================================================
|
||||
|
||||
#include <ulib/db/rdb.h>
|
||||
#include <ulib/command.h>
|
||||
#include <ulib/file_config.h>
|
||||
#include <ulib/utility/uhttp.h>
|
||||
#include <ulib/net/server/server.h>
|
||||
#include <ulib/utility/websocket.h>
|
||||
#include <ulib/utility/string_ext.h>
|
||||
#include <ulib/net/server/plugin/mod_http.h>
|
||||
|
||||
|
@ -82,6 +81,7 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
|
|||
//
|
||||
// CGI_TIMEOUT timeout for cgi execution
|
||||
// VIRTUAL_HOST flag to activate practice of maintaining more than one server on one machine, as differentiated by their apparent hostname
|
||||
// WEBSOCKET_TIMEOUT timeout for websocket request
|
||||
// DIGEST_AUTHENTICATION flag authentication method (yes = digest, no = basic)
|
||||
//
|
||||
// ENABLE_CACHING_BY_PROXY_SERVERS enable caching by proxy servers (add "Cache control: public" directive)
|
||||
|
@ -159,6 +159,10 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
UWebSocket::timeoutMS = cfg.readLong(U_CONSTANT_TO_PARAM("WEBSOCKET_TIMEOUT"), -1); // -1 => no timeout, i.e. an infinite wait
|
||||
|
||||
if (UWebSocket::timeoutMS > 0) UWebSocket::timeoutMS *= 1000;
|
||||
|
||||
# ifdef USE_LIBPCRE
|
||||
x = cfg.at(U_CONSTANT_TO_PARAM("REWRITE_RULE_NF"));
|
||||
|
||||
|
|
|
@ -41,9 +41,10 @@
|
|||
#define U_WS_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
||||
#define U_WS_GUID_LEN 36
|
||||
|
||||
int UWebSocket::status_code;
|
||||
int UWebSocket::fd_stderr;
|
||||
int UWebSocket::status_code;
|
||||
int UWebSocket::message_type;
|
||||
int UWebSocket::timeoutMS;
|
||||
vPF UWebSocket::on_message;
|
||||
vPFu UWebSocket::on_message_param;
|
||||
UString* UWebSocket::rbuffer;
|
||||
|
@ -171,7 +172,7 @@ int UWebSocket::handleDataFraming(USocket* socket)
|
|||
|
||||
loop:
|
||||
if (rbuffer->empty() &&
|
||||
USocketExt::read(socket, *rbuffer, U_SINGLE_READ, UServer_Base::timeoutMS) == false)
|
||||
USocketExt::read(socket, *rbuffer, U_SINGLE_READ, UWebSocket::timeoutMS) == false)
|
||||
{
|
||||
status_code = U_WS_STATUS_CODE_INTERNAL_ERROR;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user