Qore HttpServerUtil Module Reference 1.3
Loading...
Searching...
No Matches
HttpServerUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* HttpServerUtil.qm Copyright (C) 2014 - 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
26
27
286
290namespace HttpServer {
292const HttpServerVersion = "1.2";
293
295const HttpServerString = sprintf("Qore-HTTP-Server/%s", HttpServerVersion);
296
298const DefaultTimeout = 30s; # recvs timeout after 30 seconds
299
302
304
308const MaxSslFileLen = 1024 * 1024;
309
311const HttpCodes = ...;
312
313
318const LP_LOGPARAMS = 1 << 16;
319
323
325public hashdecl HttpResponseInfo {
327 int code;
328
330
335 *data body;
336
338
343 *InputStream chunked_body;
344
346 softbool close = False;
347
349 *hash<auto> hdr;
350
352 bool reply_sent = False;
353
355 string log;
356
358 string errlog;
359
361 *hash<auto> user_state;
362};
363
365public hashdecl HttpHandlerResponseInfo {
367 int code;
368
370
373 auto body;
374
376 softbool close = False;
377
379
382 *hash<auto> hdr;
383
385 bool reply_sent = False;
386
388 string log;
389
391 string errlog;
392
394 *hash<auto> user_state;
395};
396
397// hashdecl for SSL info
398public hashdecl HttpCertInfo {
400
402 *string cert_loc;
403
405
407 *string key_loc;
408
410
412 *string key_password;
413
415 *SSLCertificate cert;
417 *SSLPrivateKey key;
418};
419
421public hashdecl HttpListenerOptionInfo {
423 *string node;
424
426 *softstring service;
427
429 *string name;
430
432
434 *string cert_loc;
435
437
439 *string key_loc;
440
442
445
448
451
453 *hash<string, hash<HttpHandlerConfigInfo>> handler_info;
454
456 *LoggerInterface logger;
457
459 *code stopc;
460
462 int family = AF_UNSPEC;
463
465
468 bool get_remote_certs = False;
469
471
474
476
479
481 hash<auto> ext_info;
482};
483
485public hashdecl HttpHandlerConfigInfo {
487 string path = "/";
488
490 bool isregex = False;
491
493 softlist<softstring> content_types;
494
497
499 softlist<softstring> headers;
500};
501
503
507 string http_get_url_from_bind(softstring bind, *string host);
508
509
511
522 hash<Util::UriQueryInfo> parse_uri_query(string path);
523
524
526 nothing http_set_reply_headers(Socket s, hash<auto> cx, reference<auto> rv, *string server_string);
527
528
530
543 string http_mask_data(string msg);
544
545
547
558 hash<HttpListenerOptionInfo> http_get_listener_options(*string node, *softstring service, *string cert_loc, *string key_loc, *string key_password);
559
560
562
572 hash<HttpListenerOptionInfo> http_get_listener_options_from_bind(*softstring bind, *string cert_loc, *string key_loc, *string key_password);
573
574
576
582 hash<HttpListenerOptionInfo> http_get_listener_options_from_bind(*softstring bind, hash<auto> listener_params, hash<HttpListenerOptionInfo> opts = <HttpListenerOptionInfo>{});
583
584
586
596 hash<HttpCertInfo> http_get_ssl_objects(hash<auto> listener_params);
597
598
600
610 hash<HttpCertInfo> http_get_ssl_objects(string cert_loc, *string key_loc, *string pwd);
611
612
615
616public:
618
621 abstract log(string fmt, ...);
622
624
627 abstract logError(string fmt, ...);
628
630
632 logArgs(*softlist<auto> args);
633
634
636
638 logErrorArgs(*softlist<auto> args);
639
640};
641
644
645public:
647
650 logResponse(hash<auto> cx, hash<auto> rv);
651
652
655
656
658
661 abstract addUserThreadContext(hash<auto> uctx);
662
664
667 abstract auto removeUserThreadContext(*string k);
668};
669
670// for backwared compatibility, calls to deprecated methods are made below
671
673
676
677public:
679
683
684
686
688 string getRealm();
689
690
692
702 authenticate(reference<hash<auto>> cx, string user, string pass = '');
703
704
706
715 authenticateByIP(reference<hash<auto>> cx, string ip, reference<bool> authenticated);
716
717
719
729 deprecated authenticate(string user, string pass = '');
730
732
742 deprecated authenticateByIP(string ip, reference<string> user);
743
745
747 hash<auto> getAuthHeader();
748
749
751
753 hash<auto> getAuthHeader(hash<auto> cx);
754
755
757
760 hash<HttpResponseInfo> do401(string msg = 'Authentication is required to access this server', *hash<auto> cx);
761
762
764
775 *hash<HttpResponseInfo> authenticateRequest(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx);
776
777
779
789protected:
790 *hash<HttpResponseInfo> authenticateRequestIntern(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx, reference<bool> authenticated);
791public:
792
793
794protected:
795 *hash<HttpResponseInfo> processBasicAuthorizationHeader(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx, reference<bool> authenticated);
796public:
797
798
799protected:
800 *hash<HttpResponseInfo> processDigestAuthorizationHeader(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx, reference<bool> authenticated);
801public:
802
803
804protected:
805 *hash<HttpResponseInfo> processBearerAuthorizationHeader(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx, reference<bool> authenticated);
806public:
807
808
809protected:
810 *hash<HttpResponseInfo> processCookieHeader(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx, reference<bool> authenticated);
811public:
812
813
815
820
821};
822
825
826public:
828
835 *hash<HttpResponseInfo> authenticateRequest(HttpListenerInterface listener, hash<auto> hdr, reference<hash> cx);
836
837};
838
840
857
858public:
859
860
861protected:
867 Socket s;
869 hash<auto> cx;
871 hash<auto> hdr;
873 auto body;
876
877public:
878
880
892
893
895 hash<HttpHandlerResponseInfo> handleRequest();
896
897
899
907protected:
908 hash<HttpHandlerResponseInfo> sendResponse();
909public:
910
911
913
924protected:
925 hash<HttpHandlerResponseInfo> getResponseHeaderMessage();
926public:
927
928
930
932protected:
933 nothing recv(hash<auto> v);
934public:
935
936
938
941protected:
942 auto send();
943public:
944
945
947
956protected:
957 logChunk(bool send, int size);
958public:
959
960
962
977protected:
978 hash<HttpResponseInfo> getResponseHeaderMessageImpl();
979public:
980
981
983
1000protected:
1001 nothing recvImpl(hash<auto> v);
1002public:
1003
1004
1006
1013protected:
1014 auto sendImpl();
1015public:
1016
1017};
1018
1020
1028
1029public:
1032
1034 bool decompress = True;
1035
1037
1040
1043
1046
1048 const NotificationThreadKey = "_AHRH_pc";
1049
1051 const PersistenceThreadKey = "_AHRH_p";
1052
1054
1059 constructor(*AbstractAuthenticator n_auth, softbool n_stream = False);
1060
1061
1064
1065
1067 setPersistent(bool p = True);
1068
1069
1072
1073
1075
1082 *hash<HttpResponseInfo> preprocessRequest(HttpListenerInterface listener, reference<hash<auto>> hdr, reference<hash<auto>> cx);
1083
1084
1086
1094 *hash<HttpResponseInfo> authenticateRequest(HttpListenerInterface listener, hash<auto> hdr, reference<hash<auto>> cx);
1095
1096
1098
1102 string maskData(string msg);
1103
1104
1107
1110
1113
1114
1116protected:
1117 nothing checkPersistent(hash<auto> cx, hash<auto> hdr);
1118public:
1119
1120
1122
1140 hash<HttpResponseInfo> handleExpectHeader(hash<auto> cx, hash<auto> hdr);
1141
1142
1144
1163 hash<HttpResponseInfo> handleRequest(hash<auto> cx, hash<auto> hdr, *data body);
1164
1165
1167 hash<HttpResponseInfo> handleRequest(HttpListenerInterface listener, Socket s, hash<auto> cx, hash<auto> hdr, *data body);
1168
1169
1171protected:
1172 AbstractStreamRequest getStreamRequestImpl(HttpListenerInterface listener, Socket s, hash<auto> cx, hash<auto> hdr, *data body);
1173public:
1174
1175
1177 static data decodeBody(string content_encoding, binary body, *string string_encoding);
1178
1180 static binary encodeBody(string content_encoding, data body);
1181
1183 *data getMessageBody(Socket s, hash<auto> hdr, *data body, bool decode = True);
1184
1185
1187
1194 static *string getLogMessage(hash<auto> cx, hash api, reference params, *reference<string> args);
1195
1197
1201 *hash<auto> saveThreadLocalData();
1202
1203
1205
1207 restoreThreadLocalData(*hash<auto> data);
1208
1209
1211 static hash<HttpResponseInfo> makeResponse(int code, string fmt, ...);
1212
1214 static hash<HttpResponseInfo> makeResponse(hash<auto> hdr, int code, string fmt, ...);
1215
1217 static hash<HttpResponseInfo> makeResponse(int code, binary body);
1218
1220 static hash<HttpResponseInfo> makeResponse(hash<auto> hdr, int code, binary body);
1221
1223 static hash<HttpResponseInfo> makeResponse(int code, *data body, *hash<auto> hdr);
1224
1226
1228 static hash<HttpResponseInfo> makeResponse(int code, *InputStream chunked_body, *hash<auto> hdr);
1229
1231 static hash<HttpResponseInfo> make200(string fmt, ...);
1232
1234 static hash<HttpResponseInfo> make200(hash<auto> hdr, string fmt, ...);
1235
1237 static hash<HttpResponseInfo> make200(hash<auto> hdr, InputStream chunked_body);
1238
1240 static hash<HttpResponseInfo> make200(InputStream chunked_body);
1241
1243 static hash<HttpResponseInfo> make400(string fmt, ...);
1244
1246 static hash<HttpResponseInfo> make400(hash<auto> hdr, string fmt, ...);
1247
1249 static hash<HttpResponseInfo> make500(string fmt, ...);
1250
1252 static hash<HttpResponseInfo> make500(hash<auto> hdr, string fmt, ...);
1253
1255 static hash<HttpResponseInfo> make501(string fmt, ...);
1256
1258 static hash<HttpResponseInfo> make501(hash<auto> hdr, string fmt, ...);
1259
1261 static hash<HttpResponseInfo> redirect(hash<auto> cx, hash<auto> request_hdr, string path, int status_code = 301, *hash<auto> response_hdr);
1262};
1263
1266
1267public:
1269 string url_root;
1270
1272
1277
1278
1280
1283 string getRelativePath(string path);
1284
1285};
1286
1288
1306
1307public:
1308protected:
1310 bool stop = False;
1311
1313 hash<string, int> lh;
1314
1316 hash<string, bool> lsh;
1317
1319 Mutex m();
1320
1321public:
1322
1324 code setExternallyManaged(softstring lid, hash<auto> cx, Socket s);
1325
1326
1328
1337 bool start(softstring lid, hash<auto> cx, hash<auto> hdr, Socket s);
1338
1339
1341
1349 stop(softstring lid);
1350
1351
1353
1359
1360
1362protected:
1363 handlerStopped(softstring lid);
1364public:
1365
1366
1368
1378protected:
1379 abstract bool startImpl(softstring lid, hash<auto> cx, hash<auto> hdr, Socket s);
1380public:
1381
1383
1388protected:
1389 stopImpl(string lid);
1390public:
1391
1392
1394
1396protected:
1398public:
1399
1400};
1401
1403
1415};
abstract base class for external authentication
Definition HttpServerUtil.qm.dox.h:675
hash< HttpResponseInfo > do401(string msg='Authentication is required to access this server', *hash< auto > cx)
returns a 401 response with the given string argument as the message body
authenticate(reference< hash< auto > > cx, string user, string pass='')
called to authenticate a user for a connection
hash< auto > getAuthHeader()
returns a hash with one item - WWW-Authenticate header set to correct realm
*hash< HttpResponseInfo > authenticateRequestIntern(HttpListenerInterface listener, hash< auto > hdr, reference< hash< auto > > cx, reference< bool > authenticated)
Primary method called to authenticate each request.
bool requiresAuthentication()
called to check if the connection requires authentication
deprecated authenticateByIP(string ip, reference< string > user)
called when the connection requires authentication, but no authentication credentials were supplied,...
*hash< HttpResponseInfo > authenticateRequest(HttpListenerInterface listener, hash< auto > hdr, reference< hash< auto > > cx)
Primary method called to authenticate each request.
string getRealm()
returns the authentication realm as a string
hash< auto > getAuthHeader(hash< auto > cx)
returns a hash with one item - WWW-Authenticate header set to correct realm
deprecated authenticate(string user, string pass='')
called to authenticate a user for a connection
authenticateByIP(reference< hash< auto > > cx, string ip, reference< bool > authenticated)
Called to try to authenticate the connection based on the source IP address.
endRequest()
Called after a request has been handled to allow the authenticator to remove any thread-local auth in...
abstract class that all HTTP request handler objects must inherit from
Definition HttpServerUtil.qm.dox.h:1027
hash< HttpResponseInfo > handleRequest(HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
top-level request handling method
hash< HttpResponseInfo > handleRequest(hash< auto > cx, hash< auto > hdr, *data body)
will be called when a request is received that should be directed to the handler
bool stream
if the handler supports streaming requests/responses with chunked data
Definition HttpServerUtil.qm.dox.h:1042
static hash< HttpResponseInfo > make400(hash< auto > hdr, string fmt,...)
creates a hash for an HTTP 400 error response with the response message body as a string
notifyClosed(*code c)
calls the argument when the persistent connection is closed
restoreThreadLocalData(*hash< auto > data)
called after handleRequest() with any data returned from saveThreadData()
*hash< HttpResponseInfo > preprocessRequest(HttpListenerInterface listener, reference< hash< auto > > hdr, reference< hash< auto > > cx)
Preproecsses a request before authentication.
static hash< HttpResponseInfo > makeResponse(hash< auto > hdr, int code, string fmt,...)
creates a hash for an HTTP response with the response code and the response message body as a formatt...
timeout timeout_ms
send and receive socket timeout in milliseconds
Definition HttpServerUtil.qm.dox.h:1045
static hash< HttpResponseInfo > make501(hash< auto > hdr, string fmt,...)
creates a hash for an HTTP 501 error response with the response message body as a string
static hash< HttpResponseInfo > make500(string fmt,...)
creates a hash for an HTTP 500 error response with the response message body as a string
const NotificationThreadKey
thread-local key string for notification callbacks
Definition HttpServerUtil.qm.dox.h:1048
*hash< HttpResponseInfo > authenticateRequest(HttpListenerInterface listener, hash< auto > hdr, reference< hash< auto > > cx)
Authenticates the request if possible.
bool decompress_to_string
if automatically decompressed POSTed data should be converted to a string
Definition HttpServerUtil.qm.dox.h:1039
static hash< HttpResponseInfo > make200(hash< auto > hdr, string fmt,...)
creates a hash for an HTTP 200 OK error response with the response message body as a string
static hash< HttpResponseInfo > make200(string fmt,...)
creates a hash for an HTTP 200 OK error response with the response message body as a string
static data decodeBody(string content_encoding, binary body, *string string_encoding)
decodes a message body with content-encoding
static hash< HttpResponseInfo > makeResponse(int code, *data body, *hash< auto > hdr)
creates a hash for an HTTP response with the response code and a literal response message body
const PersistenceThreadKey
thread-local key string for the persistent flag
Definition HttpServerUtil.qm.dox.h:1051
AbstractStreamRequest getStreamRequestImpl(HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
returns the AbstractStreamRequest object for handling chunked requests
static hash< HttpResponseInfo > make200(InputStream chunked_body)
creates a hash for an HTTP 200 OK error response with the response message body from an input stream
static hash< HttpResponseInfo > make400(string fmt,...)
creates a hash for an HTTP 400 error response with the response message body as a string
*AbstractAuthenticator auth
the optional AbstractAuthenticator for requests to this handler
Definition HttpServerUtil.qm.dox.h:1031
static hash< HttpResponseInfo > makeResponse(int code, *InputStream chunked_body, *hash< auto > hdr)
creates a hash for an HTTP response with the response code and a response message body from an input ...
bool isPersistent()
returns True if the current connection is persistent, False if not
static staticPersistenceCleanup()
removes the thread-local data key in case the object is destroyed in another thread
static hash< HttpResponseInfo > makeResponse(hash< auto > hdr, int code, binary body)
creates a hash for an HTTP response with the response code and the response message body as binary da...
*data getMessageBody(Socket s, hash< auto > hdr, *data body, bool decode=True)
optionally retrieves and post-processes any message body
static binary encodeBody(string content_encoding, data body)
encodes a message body with content-encoding
nothing persistentClosed()
called externally when a persistent connection is closed
constructor(*AbstractAuthenticator n_auth, softbool n_stream=False)
create the object optionally with the given AbstractAuthenticator
static hash< HttpResponseInfo > make500(hash< auto > hdr, string fmt,...)
creates a hash for an HTTP 500 error response with the response message body as a string
nothing checkPersistent(hash< auto > cx, hash< auto > hdr)
this method will throw an exception if a persistent connection cannot be granted
bool decompress
if POSTed data should be decompressed automatically if there is content-encoding
Definition HttpServerUtil.qm.dox.h:1034
static *string getLogMessage(hash< auto > cx, hash api, reference params, *reference< string > args)
helper method for handling log messages
*hash< auto > saveThreadLocalData()
called before handleRequest()
static hash< HttpResponseInfo > makeResponse(int code, string fmt,...)
creates a hash for an HTTP response with the response code and the response message body as a formatt...
static hash< HttpResponseInfo > make501(string fmt,...)
creates a hash for an HTTP 501 error response with the response message body as a string
string maskData(string msg)
this method can be used to mask data in debug messages
static hash< HttpResponseInfo > make200(hash< auto > hdr, InputStream chunked_body)
creates a hash for an HTTP 200 OK error response with the response message body from an input stream
hash< HttpResponseInfo > handleExpectHeader(hash< auto > cx, hash< auto > hdr)
Called if the request contains an "Expect: 100-continue" header.
static staticNotificationCleanup()
removes the thread-local data key in case the object is destroyed in another thread
static hash< HttpResponseInfo > makeResponse(int code, binary body)
creates a hash for an HTTP response with the response code and the response message body as binary da...
static hash< HttpResponseInfo > redirect(hash< auto > cx, hash< auto > request_hdr, string path, int status_code=301, *hash< auto > response_hdr)
generates a redirect hash for the given path
setPersistent(bool p=True)
called externally to notify the handler that the connection will be persistent
abstract class that all HTTP dedicated socket handler objects must inherit from
Definition HttpServerUtil.qm.dox.h:1405
constructor(*AbstractAuthenticator auth)
create the object optionally with the given AbstractAuthenticator
Abstract class for HTTP handlers for handling protocol switching.
Definition HttpServerUtil.qm.dox.h:1305
stop(softstring lid)
called from the HTTP server when the socket should be closed due to an HTTP listener being stopped
stopImpl()
called from the HTTP server when the socket should be closed due to an external request
abstract bool startImpl(softstring lid, hash< auto > cx, hash< auto > hdr, Socket s)
called from the HTTP server after the handleRequest() method indicates that a dedicated connection sh...
Mutex m()
listener reference hash mutex
hash< string, int > lh
hash of listener references; this is to stop all connections associated with a particular listener
Definition HttpServerUtil.qm.dox.h:1313
handlerStopped(softstring lid)
Called when the handler stops.
code setExternallyManaged(softstring lid, hash< auto > cx, Socket s)
Returns a closure that can be used to confirm that the connection has been closed.
hash< string, bool > lsh
hash of listener stop flags
Definition HttpServerUtil.qm.dox.h:1316
bool stop
stop listener flag
Definition HttpServerUtil.qm.dox.h:1310
bool start(softstring lid, hash< auto > cx, hash< auto > hdr, Socket s)
called from the HTTP server after the handleRequest() method indicates that a dedicated connection sh...
stop()
called from the HTTP server when the socket should be closed due to an external request
stopImpl(string lid)
called from the HTTP server when the socket should be closed because the listener is stopping
this abstract class defines the interface for classes that provide logging methods
Definition HttpServerUtil.qm.dox.h:614
logArgs(*softlist< auto > args)
calls log() with the given args
abstract logError(string fmt,...)
called to log error information to the registered error log code
logErrorArgs(*softlist< auto > args)
calls logError() with the given args
abstract log(string fmt,...)
called to log information to the registered log code
abstract class for streaming HTTP chunked requests/responses
Definition HttpServerUtil.qm.dox.h:856
auto sendImpl()
callback method for sending chunked data
hash< auto > cx
the call context variable
Definition HttpServerUtil.qm.dox.h:869
hash< auto > hdr
a hash of request headers
Definition HttpServerUtil.qm.dox.h:871
constructor(HttpListenerInterface listener, AbstractHttpRequestHandler handler, Socket s, hash< auto > cx, hash< auto > hdr, auto body)
creates the object with the given attributes
auto send()
this is the primary callback for sending chunked responses
logChunk(bool send, int size)
this method can be overridden in base classes to log each HTTP chunk sent
AbstractHttpRequestHandler handler
the request handler for the request
Definition HttpServerUtil.qm.dox.h:865
nothing recvImpl(hash< auto > v)
callback method for receiving chunked data; the default implementation in this base class does nothin...
Socket s
the Socket object for the response
Definition HttpServerUtil.qm.dox.h:867
hash< HttpHandlerResponseInfo > handleRequest()
handles the request
HttpListenerInterface listener
an HttpListenerInterface object for the listener serving the request for logging purposes
Definition HttpServerUtil.qm.dox.h:863
timeout timeout_ms
send and receive timeout
Definition HttpServerUtil.qm.dox.h:875
hash< HttpHandlerResponseInfo > getResponseHeaderMessage()
this method returns the response message description hash by calling getResponseHeaderMessageImpl()
auto body
any message body given in a non-chunked request; could already be deserialized
Definition HttpServerUtil.qm.dox.h:873
nothing recv(hash< auto > v)
this is the primary callback for receiving chunked data; data will be logged, and then recvImpl() is ...
hash< HttpResponseInfo > getResponseHeaderMessageImpl()
this method should return the response message description hash
hash< HttpHandlerResponseInfo > sendResponse()
called to either create the response hash or send a chunked response directly
abstract class for HTTP request handlers anchored at a specific URL
Definition HttpServerUtil.qm.dox.h:1265
string url_root
root part of URL for matching requests
Definition HttpServerUtil.qm.dox.h:1269
constructor(string url_root, *AbstractAuthenticator auth)
creates the object based on the URL root and optional authenticator
string getRelativePath(string path)
returns the relative path anchored from the url_root if possible
this abstract class defines the public interface of the private HttpListener class defined in the Htt...
Definition HttpServerUtil.qm.dox.h:643
abstract addUserThreadContext(hash< auto > uctx)
adds user-defined data to be returned in the "uctx" context key when serving requests from this liste...
abstract auto removeUserThreadContext(*string k)
removes the given key from the "uctx" context key
removeExternalDedicatedSocket(softstring id)
Removes a dedicated socket handler from the listener.
logResponse(hash< auto > cx, hash< auto > rv)
method to log a response message
class providing automatic authentication for all requests
Definition HttpServerUtil.qm.dox.h:824
*hash< HttpResponseInfo > authenticateRequest(HttpListenerInterface listener, hash< auto > hdr, reference< hash > cx)
primary method called to authenticate each request
const LP_LEVELMASK
mask for the log level
Definition HttpServerUtil.qm.dox.h:321
const LP_LOGPARAMS
Definition HttpServerUtil.qm.dox.h:318
the main namespace for the HttpServer and HttpServerUtil modules
Definition HttpServerUtil.qm.dox.h:290
const HttpCodes
map of HTTP result codes and text messages
Definition HttpServerUtil.qm.dox.h:311
const DefaultTimeout
default timeout in ms
Definition HttpServerUtil.qm.dox.h:298
hash< HttpCertInfo > http_get_ssl_objects(hash< auto > listener_params)
converts a hash to HTTP certificate info if possible
const HttpServerVersion
version of the HttpServer's implementation
Definition HttpServerUtil.qm.dox.h:292
const ReadTimeout
read timeout in ms
Definition HttpServerUtil.qm.dox.h:301
nothing http_set_reply_headers(Socket s, hash< auto > cx, reference< auto > rv, *string server_string)
helper function for setting HTTP response headers
string http_get_url_from_bind(softstring bind, *string host)
returns a complete URL from a bind address
hash< HttpListenerOptionInfo > http_get_listener_options(*string node, *softstring service, *string cert_loc, *string key_loc, *string key_password)
returns a listener option info hash from flat arguments
const MaxSslFileLen
maximum X.509 and private key file length
Definition HttpServerUtil.qm.dox.h:308
hash< HttpListenerOptionInfo > http_get_listener_options_from_bind(*softstring bind, *string cert_loc, *string key_loc, *string key_password)
returns a listener option info hash from flat arguments
string http_mask_data(string msg)
this function can be used to mask data in log messages
hash< Util::UriQueryInfo > parse_uri_query(string path)
parses a URI path for a arguments and a method
const HttpServerString
default HTTP server string
Definition HttpServerUtil.qm.dox.h:295
hash providing HTTP handler configuration info
Definition HttpServerUtil.qm.dox.h:485
string path
the URI path for the handler
Definition HttpServerUtil.qm.dox.h:487
softlist< softstring > headers
a list of headers that indicate that a request should be handled by the handler (optional)
Definition HttpServerUtil.qm.dox.h:499
AbstractHttpRequestHandler handler
the handler itself (required)
Definition HttpServerUtil.qm.dox.h:496
softlist< softstring > content_types
the Content-Type that the handler handles (optional)
Definition HttpServerUtil.qm.dox.h:493
bool isregex
if the URI path is a regular expression pattern
Definition HttpServerUtil.qm.dox.h:490
the return value of HTTP handler methods with potentially unserialized message bodies
Definition HttpServerUtil.qm.dox.h:365
bool reply_sent
this key can be set to True if the reply has already been sent (by a chunked callback for example)
Definition HttpServerUtil.qm.dox.h:385
*hash< auto > user_state
additional info to be added to the context (cx) variable's user_state key if the connection is not cl...
Definition HttpServerUtil.qm.dox.h:394
*hash< auto > hdr
set this key to a hash of extra header information to be returned with the response
Definition HttpServerUtil.qm.dox.h:382
string log
a string can be returned here which will be logged in the HTTP server's log file (if any)
Definition HttpServerUtil.qm.dox.h:388
string errlog
a string can be returned here which will be logged in the HTTP server's error log file (if any)
Definition HttpServerUtil.qm.dox.h:391
int code
the HTTP return code (see HttpServer::HttpCodes for possible values)
Definition HttpServerUtil.qm.dox.h:367
softbool close
set this key to True if the connection should be unconditionally closed when the handler returns
Definition HttpServerUtil.qm.dox.h:376
auto body
the message body to return in the response
Definition HttpServerUtil.qm.dox.h:373
options for new listeners
Definition HttpServerUtil.qm.dox.h:421
*string cert_loc
The X.509 certificate file location.
Definition HttpServerUtil.qm.dox.h:434
*string node
the node value for the bind
Definition HttpServerUtil.qm.dox.h:423
int family
network family
Definition HttpServerUtil.qm.dox.h:462
bool ssl_accept_all_certs
set to False to use openssl CA validation for client certificates
Definition HttpServerUtil.qm.dox.h:478
*Qore::SSLPrivateKey key
SSL key.
Definition HttpServerUtil.qm.dox.h:450
*Qore::SSLCertificate cert
SSL cert.
Definition HttpServerUtil.qm.dox.h:447
hash< auto > ext_info
Additional info added to the notification callback when listeners are started.
Definition HttpServerUtil.qm.dox.h:481
*LoggerInterface logger
logger interface
Definition HttpServerUtil.qm.dox.h:456
*hash< string, hash< HttpHandlerConfigInfo > > handler_info
handler info
Definition HttpServerUtil.qm.dox.h:453
*string key_loc
The private key file location for the X.509 certificate.
Definition HttpServerUtil.qm.dox.h:439
*string name
the name of the listener
Definition HttpServerUtil.qm.dox.h:429
bool get_remote_certs
ask for remote client certificates (causes browsers to prompt for a client cert on new connections)
Definition HttpServerUtil.qm.dox.h:468
*softstring service
the service value for the bind
Definition HttpServerUtil.qm.dox.h:426
*string key_password
The private key password, if any.
Definition HttpServerUtil.qm.dox.h:444
*code stopc
stopc stop notification closure
Definition HttpServerUtil.qm.dox.h:459
int ssl_verify_flags
SSL certificate verification constants; see SSL Verification Mode Constants.
Definition HttpServerUtil.qm.dox.h:473
the return value of HTTP handler methods where any message body has been serialized for sending over ...
Definition HttpServerUtil.qm.dox.h:325
softbool close
set this key to True if the connection should be unconditionally closed when the handler returns
Definition HttpServerUtil.qm.dox.h:346
bool reply_sent
this key can be set to True if the reply has already been sent (by a chunked callback for example)
Definition HttpServerUtil.qm.dox.h:352
string log
a string can be returned here which will be logged in the HTTP server's log file (if any)
Definition HttpServerUtil.qm.dox.h:355
*data body
the message body to return in the response
Definition HttpServerUtil.qm.dox.h:335
int code
the HTTP return code (see HttpServer::HttpCodes for possible values)
Definition HttpServerUtil.qm.dox.h:327
string errlog
a string can be returned here which will be logged in the HTTP server's error log file (if any)
Definition HttpServerUtil.qm.dox.h:358
*InputStream chunked_body
the message body to return in the response as a chunked response
Definition HttpServerUtil.qm.dox.h:343
*hash< auto > user_state
additional info to be added to the context (cx) variable's user_state key if the connection is not cl...
Definition HttpServerUtil.qm.dox.h:361
*hash< auto > hdr
set this key to a hash of extra header information to be returned with the response
Definition HttpServerUtil.qm.dox.h:349