Qore HttpServer Module Reference 1.3
Loading...
Searching...
No Matches
HttpServer.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* HttpServer.qm Copyright (C) 2012 - 2024 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
339
345namespace HttpServer {
347
353 string get_exception_string(hash<auto> ex);
354
355
357public hashdecl HttpServerOptionInfo {
360
362 bool debug = False;
363
366
368 hash<auto> hdr = {
369 "X-Powered-By": "Qore/" + Qore::VersionString,
370 };;
371
374
376 *LoggerInterface logger;
377};
378
381
382public:
386 const ReadTimeout = HttpServer::ReadTimeout; # recvs timeout after 30 seconds
388 const PollTimeout = 250ms;
389
390 // logging options
393
395 const AIFlags = AI_PASSIVE | AI_ADDRCONFIG;
396
398 const HttpMethods = ...;
399
400
403
405 const ContentEncodings = ...;
406
407
409 const DefaultIdleThreads = 10;
410
412 const CompressionThreshold = 1024;
413
424 const LLO_RECV_HEADERS = (1 << 0);
425
427 const LLO_RECV_BODY = (1 << 1);
428
430 const LLO_SEND_HEADERS = (1 << 2);
431
433 const LLO_SEND_BODY = (1 << 3);
435
437 const DefaultTtl = 75s;
438
440protected:
441 // for masking HTTP request log msgs
442 *code maskfunc;
443
444 // quit server flag
445 bool exit = False;
446
447 // if True then verbose exception info will be logged
448 bool debug;
449
450 Sequence seqSessions();
451 Sequence seqListeners();
452
453 bool stopped = False;
454
455 // permanent handlers; these handlers are never removed
456 HttpHandlerList handlers();
457
458 // default handler
459 hash<auto> defaultHandler;
460
461 // hash of listeners keyed by listener ID
462 hash<string, HttpListener> listeners;
463
464 // map of bind addresses to listener IDs
465 hash<string, int> smap;
466
467 // map of listener names to listener IDs
468 hash<string, int> nmap;
469
470 // listener Gate
471 Gate lm();
472
473 // running listener counter
474 Counter c();
475
476 // dynamic handlers
477 DynamicHttpHandlerList dhandlers();
478
479 // connection thread pool
480 ThreadPool threadPool(-1, DefaultIdleThreads);
481
482 // other misc response headers
483 hash<auto> hdr;
484
486
488 *string override_encoding;
489
491 string http_server_string;
492
494 hash<string, bool> http_methods = HttpMethods;
495
497 *LoggerInterface logger;
498
500 bool protect_last_listener = False;
501
503 date ttl = DefaultTtl;
504
505public:
507
509
531 deprecated constructor(*code logfunc, *code errlogfunc, bool dbg = False, string name = HttpServer::HttpServerString, hash<auto> hdr = {'X-Powered-By': 'Qore/' + Qore::VersionString});
532
534
536 constructor(hash<HttpServerOptionInfo> opts);
537
538
541
542
545
546
548 date getTtl();
549
550
552 setTtl(date ttl);
553
554
556
558 addHttpMethod(string m);
559
560
563
564 setDefaultTextEncoding(string enc);
565
566
567 string getDefaultTextEncoding();
568
569
571 callListenerStopCallback(code stopc, string name, hash<auto> socket_info);
572
573
575
592 final list<hash<auto>> addListeners(string bind, hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
593
594
596
609 final list<hash<auto>> addListeners(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
610
611
613
620 hash<auto> addListener(int port);
621
622
624
634 hash<auto> addListener(hash<HttpListenerOptionInfo> opts);
635
636
639
640
642
644 hash<string, hash<auto>> getListeners();
645
646
648
665 hash<auto> getListenerInfo(softint id);
666
667
669
691 hash<auto> getListenerInfoName(string name);
692
693
695
706
707
709
720
721
724
725
727
730
731
734
735
737
742 listenerStarted(int id, hash<auto> sinfo);
743
744
745 // only called from the listeners - do not call externally
746 listenerStopped(HttpListener l);
747
748
750
753
754
756
761 stopListener(softstring bind);
762
763
765
770 stopListenerID(softint id);
771
772
774
780
781
783 int getListenerTID(softint id);
784
785
788
789
791 setHandler(string name, hash<HttpHandlerConfigInfo> info);
792
793
795 setHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
796
797
799 setDynamicHandler(string name, hash<HttpHandlerConfigInfo> info);
800
801
803 setDynamicHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
804
805
808
809
812
813
815 addHandlerToListener(softstring bind, string name, hash<HttpHandlerConfigInfo> info);
816
817
819
825 addHandlerToListenerID(softint id, string name, hash<HttpHandlerConfigInfo> info);
826
827
829
839 addHandlerToListenerID(softint id, string name, string path, *softlist content_type, HttpServer::AbstractHttpRequestHandler obj, *softlist special_headers, bool isregex = True);
840
841
843 addHandlerToListener(softstring bind, string name, HttpServer::AbstractUrlHandler obj);
844
845
847
854
855
857
863 bool removeHandlerFromListenerID(softstring id, string handler_name);
864
865
867
874
875
877
887 setListenerLogOptions(softstring bind, softint code);
888
889
891
903 setListenerLogOptionsID(softint id, softint code);
904
905
907
912 int getListenerLogOptions(softstring bind);
913
914
916
921 int getListenerLogOptionsID(softint id);
922
923
925
928
929
931
933 removeDynamicHandler(string name, *bool force_immediate);
934
935
937 log(string fmt, ...);
938
939
941 logError(string fmt, ...);
942
943
945 sendHttpError(HttpListener listener, hash<auto> cx, Socket s, int code, *data msg, *InputStream chunked_msg, *hash<auto> extra_hdrs, *string encoding, bool head);
946
947
949
953 string maskData(string msg);
954
955
957
968 setMaskCode(code maskfunc);
969
970
972
977 static string getURLFromBind(softstring bind, *string host);
978
980 setDebug(bool dbg = True);
981
982
984 bool getDebug();
985
986
987 startConnection(code c);
988
989
991
996
997
999
1001protected:
1003public:
1004
1005
1007protected:
1008 setListenerLogOptionsUnlocked(softstring id, int code);
1009public:
1010
1011
1013protected:
1015public:
1016
1017
1019 static nothing setReplyHeaders(Socket s, hash<auto> cx, reference<hash<auto>> rv);
1020
1022 // don't reimplement this method; fix/enhance it in the module
1023protected:
1024 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);
1025public:
1026
1027
1028protected:
1029 final HttpListener addListenerIntern(hash<HttpListenerOptionInfo> info);
1030public:
1031
1032
1033 // don't reimplement this method; fix/enhance it in the module
1034protected:
1035 final list<hash<auto>> addINETListenersIntern(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
1036public:
1037
1038
1039 // don't reimplement this method; fix/enhance it in the module
1040protected:
1041 final hash<HttpResponseInfo> noHandlerError(hash<auto> cx, hash<auto> hdr, auto body);
1042public:
1043
1044
1045 // handles an incoming request - do not call externally; this method is called by the listeners when a request is received
1046 // don't reimplement this method; fix/enhance it in the module
1047 final handleRequest(HttpListener listener, Socket s, reference<hash<auto>> cx, hash<auto> hdr, bool head = False, HttpPersistentHandlerInfo phi, hash<auto> info, reference<bool> dedicated, reference<bool> dedicated_external);
1048
1049
1050 // sends a reply to a request
1051 // don't reimplement this method; fix/enhance it in the module
1052 final sendReply(HttpListener listener, Socket s, *HttpServer::AbstractHttpRequestHandler handler, hash<auto> rv, reference<hash> cx, hash<auto> hdr, bool head, reference<bool> dedicated, reference<bool> dedicated_external);
1053
1054
1055 // rv is "hash" to strip types
1056private:
1057 doResponse(HttpListener listener, Socket s, hash<auto> cx, hash rv);
1058public:
1059
1061};
1062
1063class HttpPersistentHandlerInfo {
1064
1065public:
1066 *DynamicHandlerHelper dhh;
1068
1069 destructor();
1070
1071
1072 assign(*DynamicHandlerHelper n_dhh, HttpServer::AbstractHttpRequestHandler n_handler);
1073
1074
1075 clear();
1076
1077};
1078
1080
1083
1084public:
1085protected:
1086 HttpServer serv;
1087 Sequence ss;
1088
1089 *hash<HttpListenerOptionInfo> opts;
1090
1091 //*SSLCertificate cert;
1092 //*SSLPrivateKey key;
1093 bool ssl = False;
1094 auto socket;
1095 hash socket_info;
1096
1097 // connection counter for normal connection threads
1098 Counter cThreads();
1099 // connection counter for dedicated socket threads
1100 Counter dThreads();
1101
1102 bool exit = False;
1103 bool stopped = False;
1104 int id;
1105
1106 // socket handler hash
1107 hash<string, AbstractHttpSocketHandlerInterface> shh;
1108
1109 // mutex
1110 Mutex m();
1111
1113 *LoggerInterface logger;
1114
1115 // stop notification closure
1116 *code stopc;
1117
1118 string name;
1119
1120 // log recv headers flag
1121 bool log_recv_headers = False;
1122
1123 // log recv body flag
1124 bool log_recv_body = False;
1125
1126 // log send headers flag
1127 bool log_send_headers = False;
1128
1129 // log send body flag
1130 bool log_send_body = False;
1131
1133 bool get_remote_certs = False;
1134
1136 int ssl_verify_flags = SSL_VERIFY_NONE;
1137
1140
1143
1144 const PollInterval = 250ms;
1145 const ListenQueue = 100;
1146 const BodyLogLimit = 40;
1147
1148 // handler ref count
1149 int handler_ref_cnt = 0;
1150
1151 // listener-specific handlers
1152 HttpHandlerList handlers();
1153
1155 const SslVerifyMap = ...;
1156
1157
1158public:
1159
1160 // TID of the background listener thread
1161 int tid;
1162
1163 // default handler info
1164 *HandlerInfo defaultHandler;
1165
1167
1174 constructor(HttpServer server, string name, int id, Sequence ss, *hash<HttpListenerOptionInfo> opts);
1175
1176
1178
1186
1187
1189 addHandlers(hash<string, hash<HttpHandlerConfigInfo>> handler_info);
1190
1191
1195 removeHandler(string handler_name);
1196
1197
1202
1203
1204 setDefaultHandler(string name);
1205
1206
1207 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1208
1209
1210 bool hasHandlers();
1211
1212
1214
1218
1219 hash getListenerSocketInfo();
1220
1221
1222 copy();
1223
1224
1225 destructor();
1226
1227
1228 logRecvHeaders(softbool flag = True);
1229
1230
1231 logRecvBody(softbool flag = True);
1232
1233
1234 logSendHeaders(softbool flag = True);
1235
1236
1237 logSendBody(softbool flag = True);
1238
1239
1240 doLogRecvBody(*data body, hash<auto> cx, hash<auto> hdr, hash<auto> info);
1241
1242
1243 hash<auto> getLogOptions();
1244
1245
1246 string getName();
1247
1248
1249 auto getAddress();
1250
1251
1252 int getID();
1253
1254
1255 bool isSecure();
1256
1257
1258 hash<auto> getInfo();
1259
1260
1261protected:
1262 setupSslIntern();
1263public:
1264
1265
1266protected:
1267 softlist<string> getSslVerifyModeList();
1268public:
1269
1270
1271 auto removeUserThreadContext(*string k);
1272
1273
1274 addUserThreadContext(hash<auto> uctx);
1275
1276
1277 stopNoWait();
1278
1279
1280 stop();
1281
1282
1283 logResponse(hash<auto> cx, int code, *data body, *hash<auto> hdr);
1284
1285
1286 logResponse(hash<auto> cx, int code, InputStream body, *hash<auto> hdr);
1287
1288
1289 logResponse(hash<auto> cx, hash<auto> rv);
1290
1291
1292 log(string fmt, ...);
1293
1294
1295 logError(string fmt, ...);
1296
1297
1298protected:
1299 mainThread();
1300public:
1301
1302
1303 // thread for handling communication per connection
1304protected:
1305 connectionThread(Socket s);
1306public:
1307
1308
1309 bool registerDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h, reference<bool> dedicated);
1310
1311
1312 removeExternalDedicatedSocket(softstring id);
1313
1314
1315 removeDedicatedSocket(softstring id, *bool managed_externally);
1316
1317};
1318}
1319
1321namespace Priv {
1322// class containing handler info
1323class HandlerInfo {
1324
1325public:
1326 string name;
1328 string path;
1329 bool isregex;
1330 // content type map
1331 *hash<string, bool> content_type_map;
1332 *list<string> special_header_list;
1333
1335
1337 constructor(string name, hash<HttpHandlerConfigInfo> info);
1338
1339
1340 bool matchContentType(string ct);
1341
1342
1344 int matchRequest(hash<auto> hdr, int score);
1345
1346
1347 stop();
1348
1349};
1350
1351// class to implement handler-handling (private)
1352class HttpHandlerList {
1353
1354public:
1355 hash<string, HandlerInfo> handlers;
1356 TreeMap treeMap();
1357
1358 /*
1359 private static checkSpecialHeaders(reference sh) {
1360 foreach auto h in (\sh) {
1361 if (h.typeCode() != NT_STRING)
1362 throw "SETHANDLER-ERROR", sprintf("entry %d in the special header list is not a string; type: %s", $#, h.type());
1363 # make sure header is in lower case for matching
1364 h = tolower(h);
1365 }
1366 }
1367 */
1368
1370 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1371
1372
1374
1377 removeHandler(string handler_name);
1378
1379
1381
1384 removeHandler(HttpServer::AbstractHttpRequestHandler handler);
1385
1386
1387 // matches a handler to the request
1388 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1389
1390
1391 bool empty();
1392
1393
1394 int size();
1395
1396};
1397
1398// class containing dynamic handler info
1399class DynamicHandlerInfo : public HandlerInfo {
1400
1401public:
1402 Counter counter();
1403
1404 constructor(string name, hash<HttpHandlerConfigInfo> info) ;
1405
1406};
1407
1408// maintains the request count for dynamic handlers (private)
1409class DynamicHandlerHelper {
1410
1411public:
1412
1413
1414protected:
1415 Counter c;
1416
1417public:
1418
1419 constructor(Counter n_c);
1420
1421
1422 destructor();
1423
1424};
1425
1426// for dynamic handler-handling (private)
1427class DynamicHttpHandlerList : public HttpHandlerList {
1428
1429public:
1430protected:
1431 RWLock dhl();
1432
1433 // issue #4173: allow dynamic handlers to be disabled before being removed
1434 hash<string, bool> disable_map;
1435
1436public:
1437
1439 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1440
1441
1443
1445 removeHandler(string name, *bool force_immediate);
1446
1447
1449
1451 disableHandler(string name);
1452
1453
1454 *DynamicHandlerInfo findHandler(hash<auto> hdr, reference<int> score, reference<DynamicHandlerHelper> dhh, *reference<string> root_path);
1455
1456};
1457
1458class HttpServerCallbackAppender : public LoggerAppenderWithLayout {
1459
1460public:
1461protected:
1462 code logfunc;
1463
1464public:
1465
1466 constructor(code logfunc) ;
1467
1468
1469 processEventImpl(int type, auto params);
1470
1471};
1472};
this class implements the listeners for the HttpServer class
Definition HttpServer.qm.dox.h:1082
removeHandler(HttpServer::AbstractHttpRequestHandler handler)
const SslVerifyMap
map for converting ssl verify flags to strings
Definition HttpServer.qm.dox.h:1155
constructor(HttpServer server, string name, int id, Sequence ss, *hash< HttpListenerOptionInfo > opts)
creates the object with the given parameters
int lock_waiting
thread waiting on lock
Definition HttpServer.qm.dox.h:1142
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:1133
int ssl_verify_flags
SSL verify flags.
Definition HttpServer.qm.dox.h:1136
bool ssl_accept_all_certs
accept all certificates
Definition HttpServer.qm.dox.h:1139
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:1113
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:386
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...
setTtl(date ttl)
Sets the connection TTL value.
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
date getTtl()
Returns the TTL value.
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
const DefaultTtl
Default connection time-to-live.
Definition HttpServer.qm.dox.h:437
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:402
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:1321
Hash for HttpServer options.
Definition HttpServer.qm.dox.h:357
*LoggerInterface logger
HTTP server logger.
Definition HttpServer.qm.dox.h:376
bool protect_last_listener
Do not allow the last listener to be stopped.
Definition HttpServer.qm.dox.h:365
bool debug
Debug flag.
Definition HttpServer.qm.dox.h:362
string name
HTTP server name.
Definition HttpServer.qm.dox.h:359
hash< auto > hdr
Headers to add in responses.
Definition HttpServer.qm.dox.h:368
date ttl
Idle disconnect time; the default is 75 seconds.
Definition HttpServer.qm.dox.h:373