Qore HttpServer Module Reference 1.1.2
Loading...
Searching...
No Matches
HttpServer.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* HttpServer.qm Copyright (C) 2012 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// need mime definitions
26
27
28
332
338namespace HttpServer {
340
346 string get_exception_string(hash<auto> ex);
347
348
350public hashdecl HttpServerOptionInfo {
353
355 bool debug = False;
356
358 hash<auto> hdr = {
359 "X-Powered-By": "Qore/" + Qore::VersionString,
360 };;
361
363 *LoggerInterface logger;
364};
365
368
369public:
373 const ReadTimeout = HttpServer::ReadTimeout; # recvs timeout after 30 seconds
375 const PollTimeout = 250ms;
376
377 // logging options
380
382 const AIFlags = AI_PASSIVE | AI_ADDRCONFIG;
383
385 const HttpMethods = {
386 "HEAD": True,
387 "POST": True,
388 "PUT": True,
389 "DELETE": True,
390 "GET": True,
391 "OPTIONS": True,
392 "PATCH": True,
393 //"TRACE": True,
394 #"CONNECT": True,
395 };
396
399
401 const ContentEncodings = {
402 "gzip": "gzip",
403 "deflate": "deflate",
404 "bzip2": "bzip2",
405 "x-gzip": "gzip",
406 "x-deflate": "deflate",
407 "x-bzip2": "bzip2",
408 };
409
411 const DefaultIdleThreads = 10;
412
414 const CompressionThreshold = 1024;
415
426 const LLO_RECV_HEADERS = (1 << 0);
427
429 const LLO_RECV_BODY = (1 << 1);
430
432 const LLO_SEND_HEADERS = (1 << 2);
433
435 const LLO_SEND_BODY = (1 << 3);
437
439protected:
440 // for masking HTTP request log msgs
441 *code maskfunc;
442
443 // quit server flag
444 bool exit = False;
445
446 // if True then verbose exception info will be logged
447 bool debug;
448
449 Sequence seqSessions();
450 Sequence seqListeners();
451
452 bool stopped = False;
453
454 // permanent handlers; these handlers are never removed
455 HttpHandlerList handlers();
456
457 // default handler
458 hash<auto> defaultHandler;
459
460 // hash of listeners keyed by listener ID
461 hash<string, HttpListener> listeners;
462
463 // map of bind addresses to listener IDs
464 hash<string, int> smap;
465
466 // map of listener names to listener IDs
467 hash<string, int> nmap;
468
469 // listener Gate
470 Gate lm();
471
472 // running listener counter
473 Counter c();
474
475 // dynamic handlers
476 DynamicHttpHandlerList dhandlers();
477
478 // connection thread pool
479 ThreadPool threadPool(-1, DefaultIdleThreads);
480
481 // other misc response headers
482 hash<auto> hdr;
483
485
487 *string override_encoding;
488
490 string http_server_string;
491
493 hash<string, bool> http_methods = HttpMethods;
494
496 *LoggerInterface logger;
497
498public:
500
502
524 deprecated constructor(*code logfunc, *code errlogfunc, bool dbg = False, string name = HttpServer::HttpServerString, hash<auto> hdr = {'X-Powered-By': 'Qore/' + Qore::VersionString});
525
527
529 constructor(hash<HttpServerOptionInfo> opts);
530
531
534
535
538
539
541
543 addHttpMethod(string m);
544
545
548
549 setDefaultTextEncoding(string enc);
550
551
552 string getDefaultTextEncoding();
553
554
556 callListenerStopCallback(code stopc, string name, hash<auto> socket_info);
557
558
560
577 final list<hash<auto>> addListeners(string bind, hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
578
579
581
594 final list<hash<auto>> addListeners(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
595
596
598
605 hash<auto> addListener(int port);
606
607
609
619 hash<auto> addListener(hash<HttpListenerOptionInfo> opts);
620
621
624
625
627
629 hash<string, hash<auto>> getListeners();
630
631
633
650 hash<auto> getListenerInfo(softint id);
651
652
654
676 hash<auto> getListenerInfoName(string name);
677
678
680
691
692
694
705
706
709
710
712
715
716
719
720
722
727 listenerStarted(int id, hash<auto> sinfo);
728
729
730 // only called from the listeners - do not call externally
731 listenerStopped(HttpListener l);
732
733
735
738
739
741
746 stopListener(softstring bind);
747
748
750
755 stopListenerID(softint id);
756
757
759
765
766
768 int getListenerTID(softint id);
769
770
773
774
776 setHandler(string name, hash<HttpHandlerConfigInfo> info);
777
778
780 setHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
781
782
784 setDynamicHandler(string name, hash<HttpHandlerConfigInfo> info);
785
786
788 setDynamicHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
789
790
793
794
797
798
800 addHandlerToListener(softstring bind, string name, hash<HttpHandlerConfigInfo> info);
801
802
804
810 addHandlerToListenerID(softint id, string name, hash<HttpHandlerConfigInfo> info);
811
812
814
824 addHandlerToListenerID(softint id, string name, string path, *softlist content_type, HttpServer::AbstractHttpRequestHandler obj, *softlist special_headers, bool isregex = True);
825
826
828 addHandlerToListener(softstring bind, string name, HttpServer::AbstractUrlHandler obj);
829
830
832
839
840
842
848 bool removeHandlerFromListenerID(softstring id, string handler_name);
849
850
852
859
860
862
872 setListenerLogOptions(softstring bind, softint code);
873
874
876
888 setListenerLogOptionsID(softint id, softint code);
889
890
892
897 int getListenerLogOptions(softstring bind);
898
899
901
906 int getListenerLogOptionsID(softint id);
907
908
910
913
914
916
918 removeDynamicHandler(string name, *bool force_immediate);
919
920
922 log(string fmt, ...);
923
924
926 logError(string fmt, ...);
927
928
930 sendHttpError(HttpListener listener, hash<auto> cx, Socket s, int code, *data msg, *InputStream chunked_msg, *hash<auto> extra_hdrs, *string encoding, bool head);
931
932
934
938 string maskData(string msg);
939
940
942
953 setMaskCode(code maskfunc);
954
955
957
962 static string getURLFromBind(softstring bind, *string host);
963
965 setDebug(bool dbg = True);
966
967
969 bool getDebug();
970
971
972 startConnection(code c);
973
974
976
981
982
984
986protected:
988public:
989
990
992protected:
993 setListenerLogOptionsUnlocked(softstring id, int code);
994public:
995
996
998protected:
1000public:
1001
1002
1004 static nothing setReplyHeaders(Socket s, hash<auto> cx, reference<hash<auto>> rv);
1005
1007 // don't reimplement this method; fix/enhance it in the module
1008protected:
1009 final HttpListener addListenerIntern(*string node, *softstring service, *Qore::SSLCertificate cert, *Qore::SSLPrivateKey key, *hash<string, hash<HttpHandlerConfigInfo>> handler_info, *LoggerInterface logger, *code stopc, *string name, int family = AF_UNSPEC);
1010public:
1011
1012
1013protected:
1014 final HttpListener addListenerIntern(hash<HttpListenerOptionInfo> info);
1015public:
1016
1017
1018 // don't reimplement this method; fix/enhance it in the module
1019protected:
1020 final list<hash<auto>> addINETListenersIntern(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
1021public:
1022
1023
1024 // don't reimplement this method; fix/enhance it in the module
1025protected:
1026 final hash<HttpResponseInfo> noHandlerError(hash<auto> cx, hash<auto> hdr, auto body);
1027public:
1028
1029
1030 // handles an incoming request - do not call externally; this method is called by the listeners when a request is received
1031 // don't reimplement this method; fix/enhance it in the module
1032 final handleRequest(HttpListener listener, Socket s, reference<hash<auto>> cx, hash<auto> hdr, bool head = False, HttpPersistentHandlerInfo phi, hash<auto> info, reference<bool> dedicated);
1033
1034
1035 // sends a reply to a request
1036 // don't reimplement this method; fix/enhance it in the module
1037 final sendReply(HttpListener listener, Socket s, *HttpServer::AbstractHttpRequestHandler handler, hash<auto> rv, reference<hash> cx, hash<auto> hdr, bool head, reference<bool> dedicated);
1038
1039
1040 // rv is "hash" to strip types
1041private:
1042 doResponse(HttpListener listener, Socket s, hash<auto> cx, hash rv);
1043public:
1044
1046};
1047
1048class HttpPersistentHandlerInfo {
1049
1050public:
1051 *DynamicHandlerHelper dhh;
1053
1054 destructor();
1055
1056
1057 assign(*DynamicHandlerHelper n_dhh, HttpServer::AbstractHttpRequestHandler n_handler);
1058
1059
1060 clear();
1061
1062};
1063
1065
1068
1069public:
1070protected:
1071 HttpServer serv;
1072 Sequence ss;
1073
1074 *hash<HttpListenerOptionInfo> opts;
1075
1076 //*SSLCertificate cert;
1077 //*SSLPrivateKey key;
1078 bool ssl = False;
1079 auto socket;
1080 hash socket_info;
1081
1082 // connection counter for normal connection threads
1083 Counter cThreads();
1084 // connection counter for dedicated socket threads
1085 Counter dThreads();
1086
1087 bool exit = False;
1088 bool stopped = False;
1089 int id;
1090
1091 // socket handler hash
1092 hash<string, AbstractHttpSocketHandlerInterface> shh;
1093
1094 // mutex
1095 Mutex m();
1096
1098 *LoggerInterface logger;
1099
1100 // stop notification closure
1101 *code stopc;
1102
1103 string name;
1104
1105 // log recv headers flag
1106 bool log_recv_headers = False;
1107
1108 // log recv body flag
1109 bool log_recv_body = False;
1110
1111 // log send headers flag
1112 bool log_send_headers = False;
1113
1114 // log send body flag
1115 bool log_send_body = False;
1116
1118 bool get_remote_certs = False;
1119
1121 int ssl_verify_flags = SSL_VERIFY_NONE;
1122
1125
1126 const PollInterval = 250ms;
1127 const ListenQueue = 100;
1128 const BodyLogLimit = 40;
1129
1130 // handler ref count
1131 int handler_ref_cnt = 0;
1132
1133 // listener-specific handlers
1134 HttpHandlerList handlers();
1135
1138 SSL_VERIFY_PEER: "SSL_VERIFY_PEER",
1139 SSL_VERIFY_FAIL_IF_NO_PEER_CERT: "SSL_VERIFY_FAIL_IF_NO_PEER_CERT",
1140 SSL_VERIFY_CLIENT_ONCE: "SSL_VERIFY_CLIENT_ONCE",
1141 };
1142
1143public:
1144
1145 // TID of the background listener thread
1146 int tid;
1147
1148 // default handler info
1149 *HandlerInfo defaultHandler;
1150
1152
1159 constructor(HttpServer server, string name, int id, Sequence ss, *hash<HttpListenerOptionInfo> opts);
1160
1161
1163
1171
1172
1174 addHandlers(hash<string, hash<HttpHandlerConfigInfo>> handler_info);
1175
1176
1180 removeHandler(string handler_name);
1181
1182
1187
1188
1189 setDefaultHandler(string name);
1190
1191
1192 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1193
1194
1195 bool hasHandlers();
1196
1197
1199
1203
1204 hash getListenerSocketInfo();
1205
1206
1207 copy();
1208
1209
1210 destructor();
1211
1212
1213 logRecvHeaders(softbool flag = True);
1214
1215
1216 logRecvBody(softbool flag = True);
1217
1218
1219 logSendHeaders(softbool flag = True);
1220
1221
1222 logSendBody(softbool flag = True);
1223
1224
1225 doLogRecvBody(*data body, hash<auto> cx, hash<auto> hdr, hash<auto> info);
1226
1227
1228 hash<auto> getLogOptions();
1229
1230
1231 string getName();
1232
1233
1234 auto getAddress();
1235
1236
1237 int getID();
1238
1239
1240 bool isSecure();
1241
1242
1243 hash<auto> getInfo();
1244
1245
1246protected:
1247 setupSslIntern();
1248public:
1249
1250
1251protected:
1252 softlist<string> getSslVerifyModeList();
1253public:
1254
1255
1256 auto removeUserThreadContext(*string k);
1257
1258
1259 addUserThreadContext(hash<auto> uctx);
1260
1261
1262 stopNoWait();
1263
1264
1265 stop();
1266
1267
1268 logResponse(hash<auto> cx, int code, *data body, *hash<auto> hdr);
1269
1270
1271 logResponse(hash<auto> cx, int code, InputStream body, *hash<auto> hdr);
1272
1273
1274 logResponse(hash<auto> cx, hash<auto> rv);
1275
1276
1277 log(string fmt, ...);
1278
1279
1280 logError(string fmt, ...);
1281
1282
1283protected:
1284 mainThread();
1285public:
1286
1287
1288 // thread for handling communication per connection
1289protected:
1290 connectionThread(Socket s);
1291public:
1292
1293
1294 bool registerDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h, reference<bool> dedicated);
1295
1296
1297 removeDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h);
1298
1299};
1300}
1301
1303namespace Priv {
1304// class containing handler info
1305class HandlerInfo {
1306
1307public:
1308 string name;
1310 string path;
1311 bool isregex;
1312 // content type map
1313 *hash<string, bool> content_type_map;
1314 *list<string> special_header_list;
1315
1317
1319 constructor(string name, hash<HttpHandlerConfigInfo> info);
1320
1321
1322 bool matchContentType(string ct);
1323
1324
1326 int matchRequest(hash<auto> hdr, int score);
1327
1328
1329 stop();
1330
1331};
1332
1333// class to implement handler-handling (private)
1334class HttpHandlerList {
1335
1336public:
1337 hash<string, HandlerInfo> handlers;
1338 TreeMap treeMap();
1339
1340 /*
1341 private static checkSpecialHeaders(reference sh) {
1342 foreach auto h in (\sh) {
1343 if (h.typeCode() != NT_STRING)
1344 throw "SETHANDLER-ERROR", sprintf("entry %d in the special header list is not a string; type: %s", $#, h.type());
1345 # make sure header is in lower case for matching
1346 h = tolower(h);
1347 }
1348 }
1349 */
1350
1352 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1353
1354
1356
1359 removeHandler(string handler_name);
1360
1361
1363
1366 removeHandler(HttpServer::AbstractHttpRequestHandler handler);
1367
1368
1369 // matches a handler to the request
1370 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1371
1372
1373 bool empty();
1374
1375
1376 int size();
1377
1378};
1379
1380// class containing dynamic handler info
1381class DynamicHandlerInfo : public HandlerInfo {
1382
1383public:
1384 Counter counter();
1385
1386 constructor(string name, hash<HttpHandlerConfigInfo> info) ;
1387
1388};
1389
1390// maintains the request count for dynamic handlers (private)
1391class DynamicHandlerHelper {
1392
1393public:
1394
1395
1396protected:
1397 Counter c;
1398
1399public:
1400
1401 constructor(Counter n_c);
1402
1403
1404 destructor();
1405
1406};
1407
1408// for dynamic handler-handling (private)
1409class DynamicHttpHandlerList : public HttpHandlerList {
1410
1411public:
1412protected:
1413 RWLock dhl();
1414
1415 // issue #4173: allow dynamic handlers to be disabled before being removed
1416 hash<string, bool> disable_map;
1417
1418public:
1419
1421 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1422
1423
1425
1427 removeHandler(string name, *bool force_immediate);
1428
1429
1431
1433 disableHandler(string name);
1434
1435
1436 *DynamicHandlerInfo findHandler(hash<auto> hdr, reference<int> score, reference<DynamicHandlerHelper> dhh, *reference<string> root_path);
1437
1438};
1439
1440class HttpServerCallbackAppender : public LoggerAppenderWithLayout {
1441
1442public:
1443protected:
1444 code logfunc;
1445
1446public:
1447
1448 constructor(code logfunc) ;
1449
1450
1451 processEventImpl(int type, auto params);
1452
1453};
1454};
this class implements the listeners for the HttpServer class
Definition: HttpServer.qm.dox.h:1067
removeHandler(HttpServer::AbstractHttpRequestHandler handler)
const SslVerifyMap
map for converting ssl verify flags to strings
Definition: HttpServer.qm.dox.h:1137
constructor(HttpServer server, string name, int id, Sequence ss, *hash< HttpListenerOptionInfo > opts)
creates the object with the given parameters
static bool stopIfNoHandlers(HttpServer::HttpListener listener)
stop listeners if there are no handlers
removeHandler(string handler_name)
addHandlers(hash< string, hash< HttpHandlerConfigInfo > > handler_info)
add handlers to the listener
bool get_remote_certs
get remote certificates
Definition: HttpServer.qm.dox.h:1118
int ssl_verify_flags
SSL verify flags.
Definition: HttpServer.qm.dox.h:1121
bool ssl_accept_all_certs
accept all certificates
Definition: HttpServer.qm.dox.h:1124
reloadCertificate()
Reloads the HTTPS certificate from the original location.
*LoggerInterface logger
listener-specific logger; if not present, then the server's logger will be used
Definition: HttpServer.qm.dox.h:1098
constructor()
Creates the server with default options and an empty logger.
stopListenerID(softint id)
stops a single listener based on its listener ID; does not return until all connections on the listen...
const ReadTimeout
default read timeout in ms
Definition: HttpServer.qm.dox.h:373
hash< string, hash< auto > > getListeners()
returns a hash of listener information
static nothing setReplyHeaders(Socket s, hash< auto > cx, reference< hash< auto > > rv)
helper method to set HTTP response headers
disableDynamicHandler(string name)
Disable dynamic handler.
final list< hash< auto > > addListeners(string bind, hash< HttpListenerOptionInfo > info, *reference< hash< string, string > > errmap)
adds one or more dedicated listeners to the server with the given bind address
clearContextInfo()
This method is called after each request to clear context info so that it does not leak into other re...
setMaskCode(code maskfunc)
sets the closure or call reference that will be used to mask sensitive data in log messages
addHandlerToListener(softstring bind, string name, hash< HttpHandlerConfigInfo > info)
adds a request handler to a listener given the listener's name or bind address
static string getHttpServerVersionString()
returns the HTTP server version string
setDefaultHandler(string name, HttpServer::AbstractHttpRequestHandler obj)
sets the default request handler when no other handler can be matched
removeDynamicHandler(string name, *bool force_immediate)
remove dynamic handler
int getListenerCount()
returns the number of running HTTP listeners
destructor()
calls stop() and destroys the object
hash< auto > addListener(hash< HttpListenerOptionInfo > opts)
adds a single global listener to the server
setDynamicHandler(string name, HttpServer::AbstractUrlHandler obj)
sets a dynamic request handler according to the arguments given
string maskData(string msg)
masks log messages by removing sensitive data
listenerStarted(int id, hash< auto > sinfo)
called from listener when the actual listener thread is running
bool removeHandlerFromListenerID(softstring id, HttpServer::AbstractHttpRequestHandler handler)
remove request handler from a listener given the listener's id
waitStop()
waits for all listeners to be stopped; call after calling HttpServer::stopNoWait()
deprecated constructor(*code logfunc, *code errlogfunc, bool dbg=False, string name=HttpServer::HttpServerString, hash< auto > hdr={ 'X-Powered-By':'Qore/'+Qore::VersionString})
creates the HttpServer
reloadListenerCertificate(int id)
Reloads an HTTPS certificate from the original location for the given listener from the listener ID.
hash< auto > getListenerInfoName(string name)
returns a hash of information about the listener given the listener name or bind ID
stopListener(softstring bind)
stops a single listener based on its name or bind address; does not return until all connections on t...
static string getURLFromBind(softstring bind, *string host)
returns a complete URL from a bind address
reloadListenerCertificateName(string name)
Reloads an HTTPS certificate from the original location for the given listener from the listener name...
copy()
throws an exception; these objects do not support copying
bool removeHandlerFromListenerID(softstring id, string handler_name)
remove request handler from a listener given the listener's id
setHandler(string name, string path, *softlist< softstring > content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist< softstring > special_headers, bool isregex=True)
sets a request handler according to the arguments given
addHandlerToListenerID(softint id, string name, hash< HttpHandlerConfigInfo > info)
adds a request handler to a listener given the listener's id
constructor(hash< HttpServerOptionInfo > opts)
Creates the server with the given options.
log(string fmt,...)
called to log information to the registered log code
addHttpMethod(string m)
add a new supported HTTP method
final list< hash< auto > > addListeners(hash< HttpListenerOptionInfo > info, *reference< hash< string, string > > errmap)
adds one or more dedicated listeners to the server with the given bind address
int getListenerTID(softint id)
gets the TID of a listener based on its listener ID
callListenerStopCallback(code stopc, string name, hash< auto > socket_info)
To call a listener's stop callback.
bool getDebug()
returns the current status of the debug flag
addHandlerToListenerID(softint id, string name, HttpServer::AbstractUrlHandler obj)
adds a request handler to a listener given the listener's id
setListenerLogOptions(softstring bind, softint code)
turns on or off header and body logging options for receive operations for the given listener
addHandlerToListener(softstring bind, string name, HttpServer::AbstractUrlHandler obj)
adds a request handler to a listener given the listener's name or bind address
logError(string fmt,...)
called to log error information to the registered error log code
setDebug(bool dbg=True)
turns on or off debugging; when debugging is enabled more verbose error messages are reported
const HttpCodes
map of HTTP result codes and text messages
Definition: HttpServer.qm.dox.h:398
hash< auto > addListener(int port)
adds a single global listener to the server
setHandler(string name, hash< HttpHandlerConfigInfo > info)
sets a request handler according to the arguments given
setListenerLogOptionsID(softint id, softint code)
turns on or off header and body logging options for receive operations for the given listener
sendHttpError(HttpListener listener, hash< auto > cx, Socket s, int code, *data msg, *InputStream chunked_msg, *hash< auto > extra_hdrs, *string encoding, bool head)
sends an HTTP error message on the socket
addHandlerToListenerID(softint id, string name, string path, *softlist content_type, HttpServer::AbstractHttpRequestHandler obj, *softlist special_headers, bool isregex=True)
adds a request handler to a listener given the listener's id
setDynamicHandler(string name, string path, *softlist< softstring > content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist< softstring > special_headers, bool isregex=True)
sets a dynamic request handler according to the arguments given
int getListenerLogOptionsUnlocked(softstring id)
returns header and body logging options for the given listener as a binary-or'ed value of listener lo...
int getListenerLogOptions(softstring bind)
returns a binary-or'ed product of listener log options corresponding to enabled log options for the g...
stopNoWait()
stops all listeners; does not wait for all connections on the listeners to close
stopListenerIDNoWait(softint id)
starts the shutdown process for a listener based on its listener ID; returns immediately
int getListenerLogOptionsID(softint id)
returns a binary-or'ed product of listener log options corresponding to enabled log options for the g...
setHandler(string name, HttpServer::AbstractUrlHandler obj)
sets a request handler according to the arguments given
setListenerLogOptionsUnlocked(softstring id, int code)
turns on or off header and body logging options for the given listener according to the option code
stop()
stops all listeners; only returns when all connections are closed on all listeners
hash< auto > getListenerInfo(softint id)
returns a hash of information about the listener given the listener ID
int getListenerIdFromBindUnlocked(string bind)
returns the listener ID from the bind name or throws an exception if not valid
setDynamicHandler(string name, hash< HttpHandlerConfigInfo > info)
sets a dynamic request handler according to the arguments given
const LP_LEVELMASK
const LP_LOGPARAMS
const VersionString
the main namespace for the HttpServer module
const HttpCodes
const HttpServerVersion
const ReadTimeout
string get_exception_string(hash< auto > ex)
returns a multi-line string from the exception hash argument suitable for logging or output on the co...
const HttpServerString
Private namespace.
Definition: HttpServer.qm.dox.h:1303
Hash for HttpServer options.
Definition: HttpServer.qm.dox.h:350
*LoggerInterface logger
HTTP server logger.
Definition: HttpServer.qm.dox.h:363
bool debug
Debug flag.
Definition: HttpServer.qm.dox.h:355
string name
HTTP server name.
Definition: HttpServer.qm.dox.h:352
hash< auto > hdr
Headers to add in responses.
Definition: HttpServer.qm.dox.h:358