Qore HttpServer Module Reference 1.1.1
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
327
333namespace HttpServer {
335
341 string get_exception_string(hash<auto> ex);
342
343
345public hashdecl HttpServerOptionInfo {
348
350 bool debug = False;
351
353 hash<auto> hdr = {
354 "X-Powered-By": "Qore/" + Qore::VersionString,
355 };;
356
358 *LoggerInterface logger;
359};
360
363
364public:
368 const ReadTimeout = HttpServer::ReadTimeout; # recvs timeout after 30 seconds
370 const PollTimeout = 250ms;
371
372 // logging options
375
377 const AIFlags = AI_PASSIVE | AI_ADDRCONFIG;
378
380 const HttpMethods = {
381 "HEAD": True,
382 "POST": True,
383 "PUT": True,
384 "DELETE": True,
385 "GET": True,
386 "OPTIONS": True,
387 "PATCH": True,
388 //"TRACE": True,
389 #"CONNECT": True,
390 };
391
394
396 const ContentEncodings = {
397 "gzip": "gzip",
398 "deflate": "deflate",
399 "bzip2": "bzip2",
400 "x-gzip": "gzip",
401 "x-deflate": "deflate",
402 "x-bzip2": "bzip2",
403 };
404
406 const DefaultIdleThreads = 10;
407
409 const CompressionThreshold = 1024;
410
421 const LLO_RECV_HEADERS = (1 << 0);
422
424 const LLO_RECV_BODY = (1 << 1);
425
427 const LLO_SEND_HEADERS = (1 << 2);
428
430 const LLO_SEND_BODY = (1 << 3);
432
434protected:
435 // for masking HTTP request log msgs
436 *code maskfunc;
437
438 // quit server flag
439 bool exit = False;
440
441 // if True then verbose exception info will be logged
442 bool debug;
443
444 Sequence seqSessions();
445 Sequence seqListeners();
446
447 bool stopped = False;
448
449 // permanent handlers; these handlers are never removed
450 HttpHandlerList handlers();
451
452 // default handler
453 hash<auto> defaultHandler;
454
455 // hash of listeners keyed by listener ID
456 hash<string, HttpListener> listeners;
457
458 // map of bind addresses to listener IDs
459 hash<string, int> smap;
460
461 // map of listener names to listener IDs
462 hash<string, int> nmap;
463
464 // listener Gate
465 Gate lm();
466
467 // running listener counter
468 Counter c();
469
470 // dynamic handlers
471 DynamicHttpHandlerList dhandlers();
472
473 // connection thread pool
474 ThreadPool threadPool(-1, DefaultIdleThreads);
475
476 // other misc response headers
477 hash<auto> hdr;
478
480
482 *string override_encoding;
483
485 string http_server_string;
486
488 hash<string, bool> http_methods = HttpMethods;
489
491 *LoggerInterface logger;
492
493public:
495
497
519 deprecated constructor(*code logfunc, *code errlogfunc, bool dbg = False, string name = HttpServer::HttpServerString, hash<auto> hdr = {'X-Powered-By': 'Qore/' + Qore::VersionString});
520
522
524 constructor(hash<HttpServerOptionInfo> opts);
525
526
529
530
533
534
536
538 addHttpMethod(string m);
539
540
543
544 setDefaultTextEncoding(string enc);
545
546
547 string getDefaultTextEncoding();
548
549
551 callListenerStopCallback(code stopc, string name, hash<auto> socket_info);
552
553
555
572 final list<hash<auto>> addListeners(string bind, hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
573
574
576
589 final list<hash<auto>> addListeners(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
590
591
593
600 hash<auto> addListener(int port);
601
602
604
614 hash<auto> addListener(hash<HttpListenerOptionInfo> opts);
615
616
619
620
622
624 hash<string, hash<auto>> getListeners();
625
626
628
645 hash<auto> getListenerInfo(softint id);
646
647
649
671 hash<auto> getListenerInfoName(string name);
672
673
675
686
687
689
700
701
704
705
707
710
711
714
715
717
722 listenerStarted(int id, hash<auto> sinfo);
723
724
725 // only called from the listeners - do not call externally
726 listenerStopped(HttpListener l);
727
728
730
733
734
736
741 stopListener(softstring bind);
742
743
745
750 stopListenerID(softint id);
751
752
754
760
761
763 int getListenerTID(softint id);
764
765
768
769
771 setHandler(string name, hash<HttpHandlerConfigInfo> info);
772
773
775 setHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
776
777
779 setDynamicHandler(string name, hash<HttpHandlerConfigInfo> info);
780
781
783 setDynamicHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
784
785
788
789
792
793
795 addHandlerToListener(softstring bind, string name, hash<HttpHandlerConfigInfo> info);
796
797
799
805 addHandlerToListenerID(softint id, string name, hash<HttpHandlerConfigInfo> info);
806
807
809
819 addHandlerToListenerID(softint id, string name, string path, *softlist content_type, HttpServer::AbstractHttpRequestHandler obj, *softlist special_headers, bool isregex = True);
820
821
823 addHandlerToListener(softstring bind, string name, HttpServer::AbstractUrlHandler obj);
824
825
827
834
835
837
843 bool removeHandlerFromListenerID(softstring id, string handler_name);
844
845
847
854
855
857
867 setListenerLogOptions(softstring bind, softint code);
868
869
871
883 setListenerLogOptionsID(softint id, softint code);
884
885
887
892 int getListenerLogOptions(softstring bind);
893
894
896
901 int getListenerLogOptionsID(softint id);
902
903
905
908
909
911
913 removeDynamicHandler(string name, *bool force_immediate);
914
915
917 log(string fmt);
918
919
921 logError(string fmt);
922
923
925 sendHttpError(HttpListener listener, hash<auto> cx, Socket s, int code, *data msg, *InputStream chunked_msg, *hash<auto> extra_hdrs, *string encoding, bool head);
926
927
929
933 string maskData(string msg);
934
935
937
948 setMaskCode(code maskfunc);
949
950
952
957 static string getURLFromBind(softstring bind, *string host);
958
960 setDebug(bool dbg = True);
961
962
964 bool getDebug();
965
966
967 startConnection(code c);
968
969
971
973protected:
975public:
976
977
979protected:
980 setListenerLogOptionsUnlocked(softstring id, int code);
981public:
982
983
985protected:
987public:
988
989
991 static nothing setReplyHeaders(Socket s, hash<auto> cx, reference<hash<auto>> rv);
992
994 // don't reimplement this method; fix/enhance it in the module
995protected:
996 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);
997public:
998
999
1000protected:
1001 final HttpListener addListenerIntern(hash<HttpListenerOptionInfo> info);
1002public:
1003
1004
1005 // don't reimplement this method; fix/enhance it in the module
1006protected:
1007 final list<hash<auto>> addINETListenersIntern(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
1008public:
1009
1010
1011 // don't reimplement this method; fix/enhance it in the module
1012protected:
1013 final hash<HttpResponseInfo> noHandlerError(hash<auto> cx, hash<auto> hdr, auto body);
1014public:
1015
1016
1017 // handles an incoming request - do not call externally; this method is called by the listeners when a request is received
1018 // don't reimplement this method; fix/enhance it in the module
1019 final handleRequest(HttpListener listener, Socket s, reference<hash<auto>> cx, hash<auto> hdr, bool head = False, HttpPersistentHandlerInfo phi, hash<auto> info, reference<bool> dedicated);
1020
1021
1022 // sends a reply to a request
1023 // don't reimplement this method; fix/enhance it in the module
1024 final sendReply(HttpListener listener, Socket s, *HttpServer::AbstractHttpRequestHandler handler, hash<auto> rv, reference<hash> cx, hash<auto> hdr, bool head, reference<bool> dedicated);
1025
1026
1027 // rv is "hash" to strip types
1028private:
1029 doResponse(HttpListener listener, Socket s, hash<auto> cx, hash rv);
1030public:
1031
1033};
1034
1035class HttpPersistentHandlerInfo {
1036
1037public:
1038 *DynamicHandlerHelper dhh;
1040
1041 destructor();
1042
1043
1044 assign(*DynamicHandlerHelper n_dhh, HttpServer::AbstractHttpRequestHandler n_handler);
1045
1046
1047 clear();
1048
1049};
1050
1052
1055
1056public:
1057protected:
1058 HttpServer serv;
1059 Sequence ss;
1060
1061 *hash<HttpListenerOptionInfo> opts;
1062
1063 //*SSLCertificate cert;
1064 //*SSLPrivateKey key;
1065 bool ssl = False;
1066 auto socket;
1067 hash socket_info;
1068
1069 // connection counter for normal connection threads
1070 Counter cThreads();
1071 // connection counter for dedicated socket threads
1072 Counter dThreads();
1073
1074 bool exit = False;
1075 bool stopped = False;
1076 int id;
1077
1078 // socket handler hash
1079 hash<string, AbstractHttpSocketHandlerInterface> shh;
1080
1081 // mutex
1082 Mutex m();
1083
1085 *LoggerInterface logger;
1086
1087 // stop notification closure
1088 *code stopc;
1089
1090 string name;
1091
1092 // log recv headers flag
1093 bool log_recv_headers = False;
1094
1095 // log recv body flag
1096 bool log_recv_body = False;
1097
1098 // log send headers flag
1099 bool log_send_headers = False;
1100
1101 // log send body flag
1102 bool log_send_body = False;
1103
1105 bool get_remote_certs = False;
1106
1108 int ssl_verify_flags = SSL_VERIFY_NONE;
1109
1112
1113 const PollInterval = 250ms;
1114 const ListenQueue = 100;
1115 const BodyLogLimit = 40;
1116
1117 // handler ref count
1118 int handler_ref_cnt = 0;
1119
1120 // listener-specific handlers
1121 HttpHandlerList handlers();
1122
1125 SSL_VERIFY_PEER: "SSL_VERIFY_PEER",
1126 SSL_VERIFY_FAIL_IF_NO_PEER_CERT: "SSL_VERIFY_FAIL_IF_NO_PEER_CERT",
1127 SSL_VERIFY_CLIENT_ONCE: "SSL_VERIFY_CLIENT_ONCE",
1128 };
1129
1130public:
1131
1132 // TID of the background listener thread
1133 int tid;
1134
1135 // default handler info
1136 *HandlerInfo defaultHandler;
1137
1139
1146 constructor(HttpServer server, string name, int id, Sequence ss, *hash<HttpListenerOptionInfo> opts);
1147
1148
1150
1158
1159
1161 addHandlers(hash<string, hash<HttpHandlerConfigInfo>> handler_info);
1162
1163
1167 removeHandler(string handler_name);
1168
1169
1174
1175
1176 setDefaultHandler(string name);
1177
1178
1179 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1180
1181
1182 bool hasHandlers();
1183
1184
1186
1190
1191 hash getListenerSocketInfo();
1192
1193
1194 copy();
1195
1196
1197 destructor();
1198
1199
1200 logRecvHeaders(softbool flag = True);
1201
1202
1203 logRecvBody(softbool flag = True);
1204
1205
1206 logSendHeaders(softbool flag = True);
1207
1208
1209 logSendBody(softbool flag = True);
1210
1211
1212 doLogRecvBody(*data body, hash<auto> cx, hash<auto> hdr, hash<auto> info);
1213
1214
1215 hash<auto> getLogOptions();
1216
1217
1218 string getName();
1219
1220
1221 auto getAddress();
1222
1223
1224 int getID();
1225
1226
1227 bool isSecure();
1228
1229
1230 hash<auto> getInfo();
1231
1232
1233protected:
1234 setupSslIntern();
1235public:
1236
1237
1238protected:
1239 softlist<string> getSslVerifyModeList();
1240public:
1241
1242
1243 auto removeUserThreadContext(*string k);
1244
1245
1246 addUserThreadContext(hash<auto> uctx);
1247
1248
1249 stopNoWait();
1250
1251
1252 stop();
1253
1254
1255 logResponse(hash<auto> cx, int code, *data body, *hash<auto> hdr);
1256
1257
1258 logResponse(hash<auto> cx, int code, InputStream body, *hash<auto> hdr);
1259
1260
1261 logResponse(hash<auto> cx, hash<auto> rv);
1262
1263
1264 log(string fmt);
1265
1266
1267 logError(string fmt);
1268
1269
1270protected:
1271 mainThread();
1272public:
1273
1274
1275 // thread for handling communication per connection
1276protected:
1277 connectionThread(Socket s);
1278public:
1279
1280
1281 bool registerDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h, reference<bool> dedicated);
1282
1283
1284 removeDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h);
1285
1286};
1287}
1288
1290namespace Priv {
1291// class containing handler info
1292class HandlerInfo {
1293
1294public:
1295 string name;
1297 string path;
1298 bool isregex;
1299 // content type map
1300 *hash<string, bool> content_type_map;
1301 *list<string> special_header_list;
1302
1304
1306 constructor(string name, hash<HttpHandlerConfigInfo> info);
1307
1308
1309 bool matchContentType(string ct);
1310
1311
1313 int matchRequest(hash<auto> hdr, int score);
1314
1315
1316 stop();
1317
1318};
1319
1320// class to implement handler-handling (private)
1321class HttpHandlerList {
1322
1323public:
1324 hash<string, HandlerInfo> handlers;
1325 TreeMap treeMap();
1326
1327 /*
1328 private static checkSpecialHeaders(reference sh) {
1329 foreach auto h in (\sh) {
1330 if (h.typeCode() != NT_STRING)
1331 throw "SETHANDLER-ERROR", sprintf("entry %d in the special header list is not a string; type: %s", $#, h.type());
1332 # make sure header is in lower case for matching
1333 h = tolower(h);
1334 }
1335 }
1336 */
1337
1339 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1340
1341
1343
1346 removeHandler(string handler_name);
1347
1348
1350
1353 removeHandler(HttpServer::AbstractHttpRequestHandler handler);
1354
1355
1356 // matches a handler to the request
1357 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1358
1359
1360 bool empty();
1361
1362
1363 int size();
1364
1365};
1366
1367// class containing dynamic handler info
1368class DynamicHandlerInfo : public HandlerInfo {
1369
1370public:
1371 Counter counter();
1372
1373 constructor(string name, hash<HttpHandlerConfigInfo> info) ;
1374
1375};
1376
1377// maintains the request count for dynamic handlers (private)
1378class DynamicHandlerHelper {
1379
1380public:
1381
1382
1383protected:
1384 Counter c;
1385
1386public:
1387
1388 constructor(Counter n_c);
1389
1390
1391 destructor();
1392
1393};
1394
1395// for dynamic handler-handling (private)
1396class DynamicHttpHandlerList : public HttpHandlerList {
1397
1398public:
1399protected:
1400 RWLock dhl();
1401
1402 // issue #4173: allow dynamic handlers to be disabled before being removed
1403 hash<string, bool> disable_map;
1404
1405public:
1406
1408 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1409
1410
1412
1414 removeHandler(string name, *bool force_immediate);
1415
1416
1418
1420 disableHandler(string name);
1421
1422
1423 *DynamicHandlerInfo findHandler(hash<auto> hdr, reference<int> score, reference<DynamicHandlerHelper> dhh, *reference<string> root_path);
1424
1425};
1426
1427class HttpServerCallbackAppender : public LoggerAppenderWithLayout {
1428
1429public:
1430protected:
1431 code logfunc;
1432
1433public:
1434
1435 constructor(code logfunc) ;
1436
1437
1438 processEventImpl(int type, auto params);
1439
1440};
1441};
this class implements the listeners for the HttpServer class
Definition: HttpServer.qm.dox.h:1054
removeHandler(HttpServer::AbstractHttpRequestHandler handler)
const SslVerifyMap
map for converting ssl verify flags to strings
Definition: HttpServer.qm.dox.h:1124
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:1105
int ssl_verify_flags
SSL verify flags.
Definition: HttpServer.qm.dox.h:1108
bool ssl_accept_all_certs
accept all certificates
Definition: HttpServer.qm.dox.h:1111
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:1085
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:368
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
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
logError(string fmt)
called to log error information to the registered error log code
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.
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
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:393
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
log(string fmt)
called to log information to the registered log code
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:1290
Hash for HttpServer options.
Definition: HttpServer.qm.dox.h:345
*LoggerInterface logger
HTTP server logger.
Definition: HttpServer.qm.dox.h:358
bool debug
Debug flag.
Definition: HttpServer.qm.dox.h:350
string name
HTTP server name.
Definition: HttpServer.qm.dox.h:347
hash< auto > hdr
Headers to add in responses.
Definition: HttpServer.qm.dox.h:353