Qore HttpServer Module Reference 1.4
Loading...
Searching...
No Matches
HttpServer.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* HttpServer.qm Copyright (C) 2012 - 2025 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
343
349namespace HttpServer {
351
357 string get_exception_string(hash<auto> ex);
358
359
361public hashdecl HttpServerOptionInfo {
364
366 bool debug = False;
367
370
372 hash<auto> hdr = {
373 "X-Powered-By": "Qore/" + Qore::VersionString,
374 };;
375
378
380 *LoggerInterface logger;
381};
382
385
386public:
390 const ReadTimeout = HttpServer::ReadTimeout; # recvs timeout after 30 seconds
392 const PollTimeout = 250ms;
393
394 // logging options
397
399 const AIFlags = AI_PASSIVE | AI_ADDRCONFIG;
400
402 const HttpMethods = ...;
403
404
407
409 const ContentEncodings = ...;
410
411
413 const DefaultIdleThreads = 10;
414
416 const CompressionThreshold = 1024;
417
428 const LLO_RECV_HEADERS = (1 << 0);
429
431 const LLO_RECV_BODY = (1 << 1);
432
434 const LLO_SEND_HEADERS = (1 << 2);
435
437 const LLO_SEND_BODY = (1 << 3);
439
441 const DefaultTtl = 75s;
442
444protected:
445 // for masking HTTP request log msgs
446 *code maskfunc;
447
448 // quit server flag
449 bool exit = False;
450
451 // if True then verbose exception info will be logged
452 bool debug;
453
454 Sequence seqSessions();
455 Sequence seqListeners();
456
457 bool stopped = False;
458
459 // permanent handlers; these handlers are never removed
460 HttpHandlerList handlers();
461
462 // default handler
463 hash<auto> defaultHandler;
464
465 // hash of listeners keyed by listener ID
466 hash<string, HttpListener> listeners;
467
468 // map of bind addresses to listener IDs
469 hash<string, int> smap;
470
471 // map of listener names to listener IDs
472 hash<string, int> nmap;
473
474 // listener Gate
475 Gate lm();
476
477 // running listener counter
478 Counter c();
479
480 // dynamic handlers
481 DynamicHttpHandlerList dhandlers();
482
483 // connection thread pool
484 ThreadPool threadPool(-1, DefaultIdleThreads);
485
486 // other misc response headers
487 hash<auto> hdr;
488
490
492 *string override_encoding;
493
495 string http_server_string;
496
498 hash<string, bool> http_methods = HttpMethods;
499
501 *LoggerInterface logger;
502
504 bool protect_last_listener = False;
505
507 date ttl = DefaultTtl;
508
509public:
511
513
535 deprecated constructor(*code logfunc, *code errlogfunc, bool dbg = False, string name = HttpServer::HttpServerString, hash<auto> hdr = {'X-Powered-By': 'Qore/' + Qore::VersionString});
536
538
540 constructor(hash<HttpServerOptionInfo> opts);
541
542
545
546
549
550
552 date getTtl();
553
554
556 setTtl(date ttl);
557
558
560
562 addHttpMethod(string m);
563
564
567
568 setDefaultTextEncoding(string enc);
569
570
571 string getDefaultTextEncoding();
572
573
575 callListenerStopCallback(code stopc, string name, hash<auto> socket_info);
576
577
579
596 final list<hash<auto>> addListeners(string bind, hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
597
598
600
613 final list<hash<auto>> addListeners(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
614
615
617
624 hash<auto> addListener(int port);
625
626
628
638 hash<auto> addListener(hash<HttpListenerOptionInfo> opts);
639
640
643
644
646
648 hash<string, hash<auto>> getListeners();
649
650
652
669 hash<auto> getListenerInfo(softint id);
670
671
673
695 hash<auto> getListenerInfoName(string name);
696
697
699
710
711
713
724
725
728
729
731
734
735
738
739
741
746 listenerStarted(int id, hash<auto> sinfo);
747
748
749 // only called from the listeners - do not call externally
750 listenerStopped(HttpListener l);
751
752
754
757
758
760
765 stopListener(softstring bind);
766
767
769
774 stopListenerID(softint id);
775
776
778
784
785
787 int getListenerTID(softint id);
788
789
792
793
795 setHandler(string name, hash<HttpHandlerConfigInfo> info);
796
797
799 setHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
800
801
803 setDynamicHandler(string name, hash<HttpHandlerConfigInfo> info);
804
805
807 setDynamicHandler(string name, string path, *softlist<softstring> content_types, HttpServer::AbstractHttpRequestHandler obj, *softlist<softstring> special_headers, bool isregex = True);
808
809
812
813
816
817
819 addHandlerToListener(softstring bind, string name, hash<HttpHandlerConfigInfo> info);
820
821
823
829 addHandlerToListenerID(softint id, string name, hash<HttpHandlerConfigInfo> info);
830
831
833
843 addHandlerToListenerID(softint id, string name, string path, *softlist content_type, HttpServer::AbstractHttpRequestHandler obj, *softlist special_headers, bool isregex = True);
844
845
847 addHandlerToListener(softstring bind, string name, HttpServer::AbstractUrlHandler obj);
848
849
851
858
859
861
867 bool removeHandlerFromListenerID(softstring id, string handler_name);
868
869
871
878
879
881
891 setListenerLogOptions(softstring bind, softint code);
892
893
895
907 setListenerLogOptionsID(softint id, softint code);
908
909
911
916 int getListenerLogOptions(softstring bind);
917
918
920
925 int getListenerLogOptionsID(softint id);
926
927
929
932
933
935
937 removeDynamicHandler(string name, *bool force_immediate);
938
939
941 log(string fmt, ...);
942
943
945 logError(string fmt, ...);
946
947
949 sendHttpError(HttpListener listener, hash<auto> cx, Socket s, int status_code, *data msg, *InputStream chunked_msg, *hash<auto> extra_hdrs, *string encoding, bool head);
950
951
953
957 string maskData(string msg);
958
959
961
972 setMaskCode(code maskfunc);
973
974
976
981 static string getURLFromBind(softstring bind, *string host);
982
984 setDebug(bool dbg = True);
985
986
988 bool getDebug();
989
990
991 startConnection(code c);
992
993
995
1000
1001
1003
1005protected:
1007public:
1008
1009
1011protected:
1012 setListenerLogOptionsUnlocked(softstring id, int code);
1013public:
1014
1015
1017protected:
1019public:
1020
1021
1023 static nothing setReplyHeaders(Socket s, hash<auto> cx, reference<hash<auto>> rv);
1024
1026 // don't reimplement this method; fix/enhance it in the module
1027protected:
1028 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);
1029public:
1030
1031
1032protected:
1033 final HttpListener addListenerIntern(hash<HttpListenerOptionInfo> info);
1034public:
1035
1036
1037 // don't reimplement this method; fix/enhance it in the module
1038protected:
1039 final list<hash<auto>> addINETListenersIntern(hash<HttpListenerOptionInfo> info, *reference<hash<string, string>> errmap);
1040public:
1041
1042
1043 // don't reimplement this method; fix/enhance it in the module
1044protected:
1045 final hash<HttpResponseInfo> noHandlerError(hash<auto> cx, hash<auto> hdr, auto body);
1046public:
1047
1048
1050
1052 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);
1053
1054
1055 // sends a reply to a request
1056 // don't reimplement this method; fix/enhance it in the module
1057 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);
1058
1059
1060 // rv is "hash" to strip types
1061private:
1062 doResponse(HttpListener listener, Socket s, hash<auto> cx, hash rv);
1063public:
1064
1066};
1067
1068class HttpPersistentHandlerInfo {
1069
1070public:
1071 *DynamicHandlerHelper dhh;
1073
1074 destructor();
1075
1076
1077 assign(*DynamicHandlerHelper n_dhh, HttpServer::AbstractHttpRequestHandler n_handler);
1078
1079
1080 clear();
1081
1082};
1083
1085
1088
1089public:
1090protected:
1091 HttpServer serv;
1092 Sequence ss;
1093
1094 *hash<HttpListenerOptionInfo> opts;
1095
1096 //*SSLCertificate cert;
1097 //*SSLPrivateKey key;
1098 bool ssl = False;
1099 auto socket;
1100 hash socket_info;
1101
1102 // connection counter for normal connection threads
1103 Counter cThreads();
1104 // connection counter for dedicated socket threads
1105 Counter dThreads();
1106
1107 bool exit = False;
1108 bool stopped = False;
1109 int id;
1110
1111 // socket handler hash
1112 hash<string, AbstractHttpSocketHandlerInterface> shh;
1113
1114 // mutex
1115 Mutex m();
1116
1118 *LoggerInterface logger;
1119
1120 // stop notification closure
1121 *code stopc;
1122
1123 string name;
1124
1125 // log recv headers flag
1126 bool log_recv_headers = False;
1127
1128 // log recv body flag
1129 bool log_recv_body = False;
1130
1131 // log send headers flag
1132 bool log_send_headers = False;
1133
1134 // log send body flag
1135 bool log_send_body = False;
1136
1138 bool get_remote_certs = False;
1139
1141 int ssl_verify_flags = SSL_VERIFY_NONE;
1142
1145
1148
1149 const PollInterval = 250ms;
1150 const ListenQueue = 100;
1151 const BodyLogLimit = 40;
1152
1153 // handler ref count
1154 int handler_ref_cnt = 0;
1155
1156 // listener-specific handlers
1157 HttpHandlerList handlers();
1158
1160 const SslVerifyMap = ...;
1161
1162
1163public:
1164
1165 // TID of the background listener thread
1166 int tid;
1167
1168 // default handler info
1169 *HandlerInfo defaultHandler;
1170
1172
1179 constructor(HttpServer server, string name, int id, Sequence ss, *hash<HttpListenerOptionInfo> opts);
1180
1181
1183
1191
1192
1194 addHandlers(hash<string, hash<HttpHandlerConfigInfo>> handler_info);
1195
1196
1200 removeHandler(string handler_name);
1201
1202
1207
1208
1209 setDefaultHandler(string name);
1210
1211
1212 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1213
1214
1215 bool hasHandlers();
1216
1217
1219
1223
1224 hash getListenerSocketInfo();
1225
1226
1227 copy();
1228
1229
1230 destructor();
1231
1232
1233 logRecvHeaders(softbool flag = True);
1234
1235
1236 logRecvBody(softbool flag = True);
1237
1238
1239 logSendHeaders(softbool flag = True);
1240
1241
1242 logSendBody(softbool flag = True);
1243
1244
1245 doLogRecvBody(*data body, hash<auto> cx, hash<auto> hdr, hash<auto> info);
1246
1247
1248 hash<auto> getLogOptions();
1249
1250
1251 string getName();
1252
1253
1254 auto getAddress();
1255
1256
1257 int getID();
1258
1259
1260 bool isSecure();
1261
1262
1263 hash<auto> getInfo();
1264
1265
1266protected:
1267 setupSslIntern();
1268public:
1269
1270
1271protected:
1272 softlist<string> getSslVerifyModeList();
1273public:
1274
1275
1276 auto removeUserThreadContext(*string k);
1277
1278
1279 addUserThreadContext(hash<auto> uctx);
1280
1281
1282 stopNoWait();
1283
1284
1285 stop();
1286
1287
1288 string getResponseLogString(hash<auto> cx, int status_code, *data body, *hash<auto> hdr);
1289
1290
1291 logResponse(hash<auto> cx, int status_code, *data body, *hash<auto> hdr);
1292
1293
1294 logResponse(hash<auto> cx, int code, InputStream body, *hash<auto> hdr);
1295
1296
1297 logResponse(hash<auto> cx, hash<auto> rv);
1298
1299
1300 // Called when an HTTP response could not be sent
1301 logResponseError(hash<auto> cx, hash<auto> rv, hash<ExceptionInfo> ex);
1302
1303
1304 log(string fmt, ...);
1305
1306
1307 logError(string fmt, ...);
1308
1309
1310protected:
1311 mainThread();
1312public:
1313
1314
1315 // thread for handling communication per connection
1316protected:
1317 connectionThread(Socket s);
1318public:
1319
1320
1321 bool registerDedicatedSocket(softstring id, HttpServer::AbstractHttpSocketHandlerInterface h, reference<bool> dedicated);
1322
1323
1324 removeExternalDedicatedSocket(softstring id);
1325
1326
1327 removeDedicatedSocket(softstring id, *bool managed_externally);
1328
1329};
1330}
1331
1333namespace Priv {
1334// class containing handler info
1335class HandlerInfo {
1336
1337public:
1338 string name;
1340 string path;
1341 bool isregex;
1342 // content type map
1343 *hash<string, bool> content_type_map;
1344 *list<string> special_header_list;
1345
1347
1349 constructor(string name, hash<HttpHandlerConfigInfo> info);
1350
1351
1352 bool matchContentType(string ct);
1353
1354
1356 int matchRequest(hash<auto> hdr, int score);
1357
1358
1359 stop();
1360
1361};
1362
1363// class to implement handler-handling (private)
1364class HttpHandlerList {
1365
1366public:
1367 hash<string, HandlerInfo> handlers;
1368 TreeMap treeMap();
1369
1370 /*
1371 private static checkSpecialHeaders(reference sh) {
1372 foreach auto h in (\sh) {
1373 if (h.typeCode() != NT_STRING)
1374 throw "SETHANDLER-ERROR", sprintf("entry %d in the special header list is not a string; type: %s", $#, h.type());
1375 # make sure header is in lower case for matching
1376 h = tolower(h);
1377 }
1378 }
1379 */
1380
1382 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1383
1384
1386
1389 removeHandler(string handler_name);
1390
1391
1393
1396 removeHandler(HttpServer::AbstractHttpRequestHandler handler);
1397
1398
1399 // matches a handler to the request
1400 *HandlerInfo findHandler(hash<auto> hdr, reference<int> score, bool finalv = False, *reference<string> root_path);
1401
1402
1403 bool empty();
1404
1405
1406 int size();
1407
1408};
1409
1410// class containing dynamic handler info
1411class DynamicHandlerInfo : public HandlerInfo {
1412
1413public:
1414 Counter counter();
1415
1416 constructor(string name, hash<HttpHandlerConfigInfo> info) ;
1417
1418};
1419
1420// maintains the request count for dynamic handlers (private)
1421class DynamicHandlerHelper {
1422
1423public:
1424
1425
1426protected:
1427 Counter c;
1428
1429public:
1430
1431 constructor(Counter n_c);
1432
1433
1434 destructor();
1435
1436};
1437
1438// for dynamic handler-handling (private)
1439class DynamicHttpHandlerList : public HttpHandlerList {
1440
1441public:
1442protected:
1443 RWLock dhl();
1444
1445 // issue #4173: allow dynamic handlers to be disabled before being removed
1446 hash<string, bool> disable_map;
1447
1448public:
1449
1451 setHandler(string name, hash<HttpHandlerConfigInfo> info);
1452
1453
1455
1457 removeHandler(string name, *bool force_immediate);
1458
1459
1461
1463 disableHandler(string name);
1464
1465
1466 *DynamicHandlerInfo findHandler(hash<auto> hdr, reference<int> score, reference<DynamicHandlerHelper> dhh, *reference<string> root_path);
1467
1468};
1469
1470class HttpServerCallbackAppender : public LoggerAppenderWithLayout {
1471
1472public:
1473protected:
1474 code logfunc;
1475
1476public:
1477
1478 constructor(code logfunc) ;
1479
1480
1481 processEventImpl(int type, auto params);
1482
1483};
1484};
this class implements the listeners for the HttpServer class
Definition HttpServer.qm.dox.h:1087
removeHandler(HttpServer::AbstractHttpRequestHandler handler)
const SslVerifyMap
map for converting ssl verify flags to strings
Definition HttpServer.qm.dox.h:1160
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:1147
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:1138
int ssl_verify_flags
SSL verify flags.
Definition HttpServer.qm.dox.h:1141
bool ssl_accept_all_certs
accept all certificates
Definition HttpServer.qm.dox.h:1144
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:1118
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:390
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:441
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:406
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
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
sendHttpError(HttpListener listener, hash< auto > cx, Socket s, int status_code, *data msg, *InputStream chunked_msg, *hash< auto > extra_hdrs, *string encoding, bool head)
sends an HTTP error message on the socket
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:1333
Hash for HttpServer options.
Definition HttpServer.qm.dox.h:361
*LoggerInterface logger
HTTP server logger.
Definition HttpServer.qm.dox.h:380
bool protect_last_listener
Do not allow the last listener to be stopped.
Definition HttpServer.qm.dox.h:369
bool debug
Debug flag.
Definition HttpServer.qm.dox.h:366
string name
HTTP server name.
Definition HttpServer.qm.dox.h:363
hash< auto > hdr
Headers to add in responses.
Definition HttpServer.qm.dox.h:372
date ttl
Idle disconnect time; the default is 75 seconds.
Definition HttpServer.qm.dox.h:377