Http API Native API

Extensions

Http Http service object.
HttpAuth Authorization.
HttpCache Cache Control.
HttpDir Directory object for the DirHandler.
HttpEndpoint Listening endpoints.
HttpHost Host Object.
HttpLimits Http limits.
HttpMonitor Monitor control structure.
HttpNet Control object for the network connection.
HttpPacket Packet object.
HttpQueue Queue object.
HttpRange Content range structure.
HttpRoute Route Control.
HttpRx Http Rx.
HttpSession Session state object.
HttpStage Pipeline Stages.
HttpStats HttpStats.
HttpStream Http request stream.
HttpTrace Trace management structure.
HttpTx Http Tx.
HttpUploadFile Upload File.
HttpUri URI management.
HttpWebSocket WebSocket Service to implement the WebSockets RFC 6455 specification for client and server communications.

Functions

HttpNet*httpAccept(HttpEndpoint *endpoint, MprEvent *event)
 Accept a new connection.
inthttpAddBodyParams(HttpStream *stream)
 Add parameters from the request body content.
voidhttpAddCache(struct HttpRoute *route, cchar *methods, cchar *uris, cchar *extensions, cchar *types, MprTicks clientLifespan, MprTicks serverLifespan, int flags)
 Add caching for response content.
HttpParseCallbackhttpAddConfig(cchar *key, HttpParseCallback callback)
 Add a configuration file callback for a property key.
inthttpAddCounter(cchar *name)
 Add a counter to be monitored.
inthttpAddDefense(cchar *name, cchar *remedy, cchar *args)
 Add a defense.
inthttpAddDefenseFromJson(cchar *name, cchar *remedy, MprJson *jargs)
 Add a defense using JSON arguments.
voidhttpAddHeader(HttpStream *stream, cchar *key, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Add a header to the transmission using a format string.
void voidhttpAddHeaderString(HttpStream *stream, cchar *key, cchar *value)
 Add a header to the transmission.
voidhttpAddHostToEndpoint(HttpEndpoint *endpoint, struct HttpHost *host)
 Add a host to an endpoint.
voidhttpAddJsonParams(HttpStream *stream)
 Add parameters from a JSON body.
inthttpAddMonitor(cchar *counter, cchar *expr, uint64 limit, MprTicks period, cchar *defenses)
 Add a monitor.
voidhttpAddOption(MprHash *options, cchar *field, cchar *value)
 Add an option to the options table.
voidhttpAddPermResource(HttpRoute *parent, cchar *resource)
 Add routes for a permanent resource.
voidhttpAddQueryParams(HttpStream *stream)
 Add parameters from the request query string.
inthttpAddRemedy(cchar *name, HttpRemedyProc remedy)
 Add a remedy.
voidhttpAddResource(HttpRoute *parent, cchar *resource)
 Add routes for a resource.
voidhttpAddResourceGroup(HttpRoute *parent, cchar *resource)
 Add routes for a group of resources.
HttpRoute*httpAddRestfulRoute(HttpRoute *parent, cchar *methods, cchar *pattern, cchar *target, cchar *resource)
 Define a RESTful route.
HttpRole*httpAddRole(HttpAuth *auth, cchar *role, cchar *abilities)
 Add a role.
inthttpAddRoute(HttpHost *host, HttpRoute *route)
 Add a route to a host.
inthttpAddRouteCondition(HttpRoute *route, cchar *name, cchar *details, int flags)
 Add a route condition.
voidhttpAddRouteErrorDocument(HttpRoute *route, int status, cchar *uri)
 Add an error document.
inthttpAddRouteFilter(HttpRoute *route, cchar *name, cchar *extensions, int direction)
 Add a route filter.
inthttpAddRouteHandler(HttpRoute *route, cchar *name, cchar *extensions)
 Add a route handler.
voidhttpAddRouteIndex(HttpRoute *route, cchar *path)
 Set the route index document.
inthttpAddRouteLanguageDir(HttpRoute *route, cchar *language, cchar *path)
 Add a route language directory.
inthttpAddRouteLanguageSuffix(HttpRoute *route, cchar *language, cchar *suffix, int flags)
 Add a route language suffix.
voidhttpAddRouteMapping(HttpRoute *route, cchar *extensions, cchar *mappings)
 Add a route mapping.
voidhttpAddRouteMethods(HttpRoute *route, cchar *methods)
 Add HTTP methods for the route.
voidhttpAddRouteParam(HttpRoute *route, cchar *field, cchar *value, int flags)
 Add a route param check.
voidhttpAddRouteRequestHeaderCheck(HttpRoute *route, cchar *header, cchar *value, int flags)
 Add a request header check.
voidhttpAddRouteResponseHeader(HttpRoute *route, int cmd, cchar *header, cchar *value)
 Add a response header.
voidhttpAddRouteSet(HttpRoute *route, cchar *set)
 Add a route set.
inthttpAddRouteUpdate(HttpRoute *route, cchar *name, cchar *details, int flags)
 Add a route update rule.
inthttpAddSecurityToken(HttpStream *stream, bool recreate)
 Add the security token to the response.
HttpUser*httpAddUser(HttpAuth *auth, cchar *user, cchar *password, cchar *abilities)
 Add a user.
HttpRoute*httpAddWebSocketsRoute(HttpRoute *route, cchar *action)
 Add a route using the WebSockets filter.
voidhttpAdjustPacketEnd(HttpPacket *packet, MprOff size)
 Adjust the packet end position.
voidhttpAdjustPacketStart(HttpPacket *packet, MprOff size)
 Adjust the packet starting position.
voidhttpAfterEvent(HttpStream *stream)
 Do setup after an I/O event to receive future events.
HttpSession*httpAllocSession(HttpStream *stream, cchar *id, MprTicks lifespan)
 Allocate a new session state object.
voidhttpAppendHeader(HttpStream *stream, cchar *key, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Append a transmission header.
void voidhttpAppendHeaderString(HttpStream *stream, cchar *key, cchar *value)
 Append a transmission header string.
inthttpApplyChangedGroup(void)
 Apply the changed group ID.
inthttpApplyChangedUser(void)
 Apply the changed user ID.
inthttpApplyUserGroup(void)
 Apply the changed user and group ID.
boolhttpAuthenticate(HttpStream *stream)
 Authenticate a user based on session data.
inthttpBackupTraceLogFile(HttpTrace *trace)
 Backup the request trace log if required.
void void voidhttpBadRequestError(HttpStream *stream, int status, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Emit an error message for a badly formatted request.
inthttpBanClient(cchar *ip, MprTicks period, int status, cchar *msg)
 Ban a client IP from service.
voidhttpBorrowNet(HttpNet *net)
 Borrow a network connection.
boolhttpCanUser(HttpStream *stream, cchar *abilities)
 Test if a user has the required abilities.
boolhttpCheckSecurityToken(HttpStream *stream)
 Check a security token.
voidhttpClearRouteStages(HttpRoute *route, int direction)
 Clear the pipeline stages for the route.
boolhttpClientStream(HttpStream *stream)
 Test if the connection is a client-side connection.
HttpHost*httpCloneHost(HttpHost *parent)
 Clone a host.
HttpPacket*httpClonePacket(HttpPacket *orig)
 Clone a packet.
HttpStage*httpCloneStage(HttpStage *stage)
 Create a clone of an existing state.
HttpUri*httpCloneUri(HttpUri *base, int flags)
 Clone a URI.
voidhttpClosePipeline(HttpStream *stream)
 Destroy the request pipeline.
voidhttpCommonTraceFormatter(HttpTrace *trace, cchar *event, cchar *type, int flags, cchar *buf, ssize len, cchar *fmt, va_list args)
 Common Log trace formatter.
HttpUri*httpCompleteUri(HttpUri *uri, HttpUri *other)
 Complete the given URI.
voidhttpComputeAllUserAbilities(HttpAuth *auth)
 Compute all the user abilities for a route using the given auth.
voidhttpComputeUserAbilities(HttpAuth *auth, HttpUser *user)
 Compute the user abilities for a given user in a route using the given auth.
boolhttpConfigure(HttpConfigureProc proc, void *arg, MprTicks timeout)
 Alter the configuration by first quiescing all Http activity.
inthttpConnect(HttpStream *stream, cchar *method, cchar *uri, struct MprSsl *ssl)
 Connect to a server and issue Http client request.
inthttpConnectNet(HttpNet *net, cchar *ip, int port, MprSsl *ssl)
 Connect the network to a remote peer.
boolhttpContentNotModified(HttpStream *stream)
 Test if the content has not been modified.
Http*httpCreate(int flags)
 Create a Http service object.
HttpRoute*httpCreateActionRoute(HttpRoute *parent, cchar *pattern, HttpAction action)
 Create a route for use with the Action Handler.
HttpRoute*httpCreateAliasRoute(HttpRoute *parent, cchar *pattern, cchar *path, int status)
 Create a route suitable for use as an alias.
HttpAuth*httpCreateAuth(void)
 Create an authentication object.
HttpAuthStore*httpCreateAuthStore(cchar *name, HttpVerifyUser verifyUser)
 Add an authorization store for password validation.
inthttpCreateAuthType(cchar *name, HttpAskLogin askLogin, HttpParseAuth parse, HttpSetAuth setAuth)
 Create an authorization protocol type.
voidhttpCreateCGIParams(HttpStream *stream)
 Create CGI parameters.
HttpEndpoint*httpCreateConfiguredEndpoint(struct HttpHost *host, cchar *home, cchar *documents, cchar *ip, int port)
 Create and configure a new endpoint.
HttpRoute*httpCreateConfiguredRoute(struct HttpHost *host, int serverSide)
 Create a configured route.
HttpPacket*httpCreateDataPacket(ssize size)
 Create a data packet.
HttpHost*httpCreateDefaultHost(void)
 Create the default host.
HttpRoute*httpCreateDefaultRoute(struct HttpHost *host)
 Create a default route for a host.
HttpPacket*httpCreateEndPacket(void)
 Create an end-of-stream packet.
HttpEndpoint*httpCreateEndpoint(cchar *ip, int port, MprDispatcher *dispatcher)
 Create an endpoint object.
HttpPacket*httpCreateEntityPacket(MprOff pos, MprOff size, HttpFillProc fill)
 Create an entity data packet.
HttpStage*httpCreateFilter(cchar *name, MprModule *module)
 Create a filter stage.
HttpStage*httpCreateHandler(cchar *name, MprModule *module)
 Create a request handler stage.
HttpPacket*httpCreateHeaderPacket(void)
 Create a response header packet.
HttpPacket*httpCreateHeaders(HttpQueue *q, HttpPacket *packet)
 Create a HTTP header packet.
HttpHost*httpCreateHost(void)
 Create a host.
HttpRoute*httpCreateInheritedRoute(HttpRoute *route)
 Create a route inherited from a parent route.
HttpLimits*httpCreateLimits(int serverSide)
 Create a new limits object.
HttpNet*httpCreateNet(MprDispatcher *dispatcher, struct HttpEndpoint *endpoint, int protocol, int flags)
 Create a network object.
HttpPacket*httpCreatePacket(ssize size)
 Create a data packet.
voidhttpCreatePipeline(HttpStream *stream)
 Create the pipeline.
HttpRoute*httpCreateRoute(struct HttpHost *host)
 Create a route for a host.
voidhttpCreateRxPipeline(HttpStream *stream, struct HttpRoute *route)
 Create the receive request pipeline.
HttpSession*httpCreateSession(HttpStream *stream)
 Create a session object.
HttpStage*httpCreateStage(cchar *name, int flags, MprModule *module)
 Create a connector stage.
HttpStream*httpCreateStream(HttpNet *net, bool peerCreated)
 Create a stream object.
HttpStage*httpCreateStreamector(cchar *name, MprModule *module)
 Create a connector stage.
HttpTrace*httpCreateTrace(HttpTrace *parent)
 Create a trace object.
HttpTx*httpCreateTx(HttpStream *stream, MprHash *headers)
 Create the tx object.
voidhttpCreateTxPipeline(HttpStream *stream, struct HttpRoute *route)
 Create the transmit request pipeline.
HttpUri*httpCreateUri(cchar *uri, int flags)
 Create and initialize a URI.
HttpUri*httpCreateUriFromParts(cchar *scheme, cchar *host, int port, cchar *path, cchar *reference, cchar *query, int flags)
 Create a URI from parts.
voidhttpDefaultIncoming(HttpQueue *q, HttpPacket *packet)
 Default incoming put callback.
voidhttpDefaultOutgoingServiceStage(HttpQueue *q)
 Default outgoing data handling.
voidhttpDefineAction(cchar *uri, HttpAction fun)
 Define a function procedure to invoke when the specified URI is requested.
HttpRoute*httpDefineRoute(HttpRoute *parent, cchar *methods, cchar *pattern, cchar *target, cchar *source)
 Define a route.
voidhttpDefineRouteCondition(cchar *name, HttpRouteProc *proc)
 Define a route condition rule.
HttpRouteSetProchttpDefineRouteSet(cchar *name, HttpRouteSetProc fn)
 Define a route set callback.
voidhttpDefineRouteTarget(cchar *name, HttpRouteProc *proc)
 Define a route target rule.
voidhttpDefineRouteUpdate(cchar *name, HttpRouteProc *proc)
 Define a route update rule.
voidhttpDestroy(void)
 Destroy the Http service.
voidhttpDestroyEndpoint(HttpEndpoint *endpoint)
 Destroy the endpoint.
voidhttpDestroyNet(HttpNet *net)
 Destroy the network object.
voidhttpDestroySession(HttpStream *stream)
 Destroy a session state object.
voidhttpDestroyStream(HttpStream *stream)
 Destroy the stream object.
voidhttpDestroyTx(HttpTx *tx)
 Destroy the tx object.
voidhttpDetailTraceFormatter(HttpTrace *trace, cchar *event, cchar *type, int flags, cchar *buf, ssize len, cchar *fmt, va_list args)
 Detailed log trace formatter.
voidhttpDiscardData(HttpStream *stream, int dir)
 Discard buffered transmit pipeline data.
voidhttpDiscardQueueData(HttpQueue *q, bool removePackets)
 Discard all data from the queue.
voidhttpDisconnectStream(HttpStream *stream)
 Disconnect the connection's socket.
voidhttpDumpCounters(void)
 Print the monitor counters to the error log.
voidhttpEaseLimits(HttpLimits *limits)
 Ease the limits.
voidhttpEnableNetEvents(HttpNet *net)
 Enable network events.
voidhttpEnableUpload(HttpStream *stream)
 Enable Multipart-Mime File Upload for this request.
voidhttpError(HttpStream *stream, int status, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Error handling for the connection.
cchar*httpExpandRouteVars(HttpRoute *route, cchar *str)
 Expand route variables in a string.
voidhttpFinalize(HttpStream *stream)
 Indicate the request is finalized.
voidhttpFinalizeConnector(HttpStream *stream)
 Finalize connector output sending the response.
voidhttpFinalizeInput(HttpStream *stream)
 Finalize receiption of the http content.
voidhttpFinalizeOutput(HttpStream *stream)
 Finalize transmission of the http response.
voidhttpFinalizeRoute(HttpRoute *route)
 Finalize a route.
voidhttpFlush(HttpStream *stream)
 Flush transmit data.
voidhttpFlushAll(HttpStream *stream)
 Flush transmit data and wait for all the data to be written to the socket.
boolhttpFlushQueue(HttpQueue *q, int flags)
 Flush queue data.
voidhttpFollowRedirects(HttpStream *stream, bool follow)
 Follow redirctions.
voidhttpFormatError(HttpStream *stream, int status, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Format an error transmission.
void ssizehttpFormatResponse(HttpStream *stream, cchar *fmt, ...) PRINTF_ATTRIBUTE(2
 Format an alternate response.
ssizehttpFormatResponseBody(HttpStream *stream, cchar *title, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Format a response body.
void ssize ssizehttpFormatResponsev(HttpStream *stream, cchar *fmt, va_list args)
 Format an alternate response.
voidhttpFormatTrace(HttpTrace *trace, cchar *event, cchar *type, int flags, cchar *buf, ssize len, cchar *fmt, va_list args)
 Convenience routine to format trace via the configured formatter.
char*httpFormatUri(cchar *scheme, cchar *host, int port, cchar *path, cchar *ref, cchar *query, int flags)
 Format a URI.
boolhttpGetAsync(HttpNet *net)
 Get the async mode value for the network.
cchar*httpGetBodyInput(HttpStream *stream)
 Get the receive body input.
boolhttpGetBoolToken(cchar *tok)
 Parse a boolean token.
void void void ssizehttpGetChunkSize(HttpStream *stream)
 Get the preferred chunked size for transfer chunk encoding.
MprOffhttpGetContentLength(HttpStream *stream)
 Get the receive body content length.
void*httpGetContext(void)
 Get the http context object.
cchar*httpGetCookie(HttpStream *stream, cchar *name)
 Get a request cookie.
cchar*httpGetCookies(HttpStream *stream)
 Get the request cookies.
char*httpGetDateString(MprPath *sbuf)
 Get the time as an ISO date string.
HttpHost*httpGetDefaultHost(void)
 Get the default host defined via httpSetDefaultHost.
HttpRoute*httpGetDefaultRoute(HttpHost *host)
 Get the default route for a host.
cchar*httpGetDir(HttpRoute *route, cchar *name)
 Get a route directory variable.
HttpDir*httpGetDirObj(HttpRoute *route)
 Get the HttpDir object for a route.
void*httpGetEndpointContext(HttpEndpoint *endpoint)
 Get the endpoint context object.
cchar*httpGetError(HttpStream *stream)
 Get the error message associated with the last request.
char*httpGetExt(HttpStream *stream)
 Get a URI extension.
cchar*httpGetHeader(HttpStream *stream, cchar *key)
 Get an rx http header.
MprHash*httpGetHeaderHash(HttpStream *stream)
 Get the hash table of rx Http headers.
char*httpGetHeaders(HttpStream *stream)
 Get all the request http headers.
char*httpGetHeadersFromHash(MprHash *hash)
 Get a header string from the given hash.
HttpRoute*httpGetHostDefaultRoute(HttpHost *host)
 Return the default route for a host.
inthttpGetIntParam(HttpStream *stream, cchar *var, int defaultValue)
 Get a form variable as an integer.
inthttpGetKeepAliveCount(HttpStream *stream)
 Get the count of Keep-Alive requests that will be used for this stream object.
HttpLang*httpGetLanguage(HttpStream *stream, MprHash *spoken, cchar *defaultLang)
 Get the language to use for the request.
void*httpGetOption(MprHash *options, cchar *field, cchar *defaultValue)
 Extract a field value from an option string.
MprHash*httpGetOptionHash(MprHash *options, cchar *field)
 Get an option value that is itself an object (hash).
MprHash*httpGetOptions(cchar *options)
 Convert an options string into an options table.
HttpPacket*httpGetPacket(struct HttpQueue *q)
 Get the next packet from a queue.
ssizehttpGetPacketContents(HttpPacket *packet)
 Get the packet data contents.
ssizehttpGetPacketLength(HttpPacket *packet)
 Get the length of the packet data contents.
char*httpGetPacketStart(HttpPacket *packet)
 Get the start of the packet data contents.
char*httpGetPacketString(HttpPacket *packet)
 Get the packet data contents as a string.
cchar*httpGetParam(HttpStream *stream, cchar *var, cchar *defaultValue)
 Get a request param.
MprJson*httpGetParams(HttpStream *stream)
 Get the request params table.
cchar*httpGetParamsString(HttpStream *stream)
 Get the request params table as a string.
char*httpGetPathExt(cchar *path)
 Get a path extension.
cchar*httpGetProtocol(HttpNet *net)
 Get the Http protocol variant for this network connection.
cchar*httpGetQueryString(HttpStream *stream)
 Get the request query string.
void*httpGetQueueData(HttpStream *stream)
 Get the queue data for the connection.
ssizehttpGetQueueRoom(HttpQueue *q)
 Get the room in the queue.
ssizehttpGetReadCount(HttpStream *stream)
 Get the number of bytes that can be read from the read queue.
HttpUri*httpGetRelativeUri(HttpUri *base, HttpUri *target, int clone)
 Get a relative URI from the base to the target.
void*httpGetRouteData(HttpRoute *route, cchar *key)
 Get extra route data.
cchar*httpGetRouteDocuments(HttpRoute *route)
 Get the route documents directory.
cchar*httpGetRouteHome(HttpRoute *route)
 Get the route home directory.
cchar*httpGetRouteMethods(HttpRoute *route)
 Get the route method list.
cchar*httpGetRouteTop(HttpStream *stream)
 Get a URL path to the top of the route from the current request (rx->pathInfo).
cchar*httpGetRouteVar(HttpRoute *route, cchar *key)
 Get a path token variable.
cchar*httpGetSecurityToken(HttpStream *stream, bool recreate)
 Get a unique security token.
HttpSession*httpGetSession(HttpStream *stream, int create)
 Get a session state object.
cchar*httpGetSessionID(HttpStream *stream)
 Get the session ID.
MprHash*httpGetSessionObj(HttpStream *stream, cchar *key)
 Get an object from the session state store.
cchar*httpGetSessionVar(HttpStream *stream, cchar *name, cchar *defaultValue)
 Get a session state variable.
cvoid*httpGetStageData(struct HttpStream *stream, cchar *key)
 Get stage data.
voidhttpGetStats(HttpStats *sp)
 Get the Http performance statistics.
inthttpGetStatus(HttpStream *stream)
 Get the response status.
cchar*httpGetStatusMessage(HttpStream *stream)
 Get the Http response status message.
void*httpGetStreamContext(HttpStream *stream)
 Get the connection context object.
inthttpGetStreamEventMask(HttpStream *stream)
 Get an IO event mask for events of interest to the connection.
void*httpGetStreamHost(HttpStream *stream)
 Get the connection host object.
boolhttpGetStreaming(struct HttpHost *host, cchar *mime, cchar *uri)
 Determine if input body content should be streamed or buffered for requests with content of a given mime type.
inthttpGetTraceLevel(void)
 Get the current tracing level.
ssize cchar*httpGetTxHeader(HttpStream *stream, cchar *key)
 Get a tx http header.
voidhttpGetUserGroup(void)
 Get the user group.
cchar*httpGetWebSocketCloseReason(HttpStream *stream)
 Get the close reason supplied by the peer.
void*httpGetWebSocketData(HttpStream *stream)
 Get the WebSocket private data.
ssizehttpGetWebSocketMessageLength(HttpStream *stream)
 Get the message length for the current message.
char*httpGetWebSocketProtocol(HttpStream *stream)
 Get the selected WebSocket protocol selected by the server.
ssizehttpGetWebSocketState(HttpStream *stream)
 Get the WebSocket state.
ssizehttpGetWriteQueueCount(HttpStream *stream)
 Get the count of bytes buffered on the write queue.
HttpLimits*httpGraduateLimits(HttpRoute *route, HttpLimits *limits)
 Graduate the limits from the parent route.
voidhttpHandleOptions(struct HttpStream *stream)
 Handle a Http Options method request.
voidhttpHideRoute(HttpRoute *route, bool on)
 Hide the route from route tables.
voidhttpIOEvent(struct HttpNet *net, MprEvent *event)
 Respond to a HTTP I/O event.
voidhttpInitConfig(HttpRoute *route)
 Initialize and prepare to load configuration files.
voidhttpInitLimits(HttpLimits *limits, bool serverSide)
 Initialize a limits object with default values.
inthttpInitParser(void)
 Initialize the Http configuration parser.
voidhttpInsertOption(MprHash *options, cchar *field, cchar *value)
 Add an option to the options table.
boolhttpIsAuthenticated(HttpStream *stream)
 Test if the user is authenticated.
inthttpIsChunked(HttpStream *stream)
 Return whether transfer chunked encoding will be used on this request.
inthttpIsEndpointAsync(HttpEndpoint *endpoint)
 Get if the endpoint is running in asynchronous mode.
boolhttpIsEof(struct HttpStream *stream)
 Test if the connection has received all incoming content.
inthttpIsFinalized(HttpStream *stream)
 Test if request has been finalized.
boolhttpIsLastPacket(HttpPacket *packet)
 Test if the packet is the last in a logical message.
inthttpIsOutputFinalized(HttpStream *stream)
 Test if request response has been fully generated.
boolhttpIsPacketTooBig(struct HttpQueue *q, HttpPacket *packet)
 Test if a packet is too big.
boolhttpIsQueueEmpty(HttpQueue *q)
 Determine if the queue is empty.
boolhttpIsQueueSuspended(HttpQueue *q)
 Test if a queue is suspended.
inthttpJoinPacket(HttpPacket *packet, HttpPacket *other)
 Join two packets.
voidhttpJoinPacketForService(struct HttpQueue *q, HttpPacket *packet, bool serviceQ)
 Join a packet onto the service queue.
voidhttpJoinPackets(HttpQueue *q, ssize size)
 Join packets together.
HttpUri*httpJoinUri(HttpUri *base, int argc, HttpUri **others)
 Join URIs.
HttpUri*httpJoinUriPath(HttpUri *result, HttpUri *base, HttpUri *other)
 Join a URI path.
void voidhttpLimitError(HttpStream *stream, int status, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Emit an error message for limit violations.
char*httpLink(struct HttpStream *stream, cchar *target)
 Create a URI link.
char*httpLinkAbs(struct HttpStream *stream, cchar *target)
 Create an absolute link that includes scheme and host.
char*httpLinkEx(struct HttpStream *stream, cchar *target, MprHash *options)
 Extended URI link creation.
inthttpLoadConfig(HttpRoute *route, cchar *path)
 Load a JSON configuration file.
voidhttpLogRoutes(HttpHost *host, bool full)
 Show the current route table to the error log.
boolhttpLogin(HttpStream *stream, cchar *username, cchar *password)
 Log the user in.
voidhttpLogout(HttpStream *stream)
 Logout the user.
struct HttpEndpoint*httpLookupEndpoint(cchar *ip, int port)
 Lookup a listening endpoint.
struct HttpHost*httpLookupHost(cchar *name)
 Lookup a host by name.
struct HttpHost*httpLookupHostOnEndpoint(HttpEndpoint *endpoint, cchar *name)
 Lookup a host name.
cchar*httpLookupMimeType(cchar *ext)
 Get the mime type for an extension.
HttpRole*httpLookupRole(HttpAuth *auth, cchar *name)
 Lookup a role by name.
HttpRoute*httpLookupRoute(HttpHost *host, cchar *pattern)
 Lookup a route by pattern.
cchar*httpLookupRouteErrorDocument(HttpRoute *route, int status)
 Lookup an error document by HTTP status code.
boolhttpLookupSessionID(cchar *id)
 Lookup a session ID.
struct HttpStage*httpLookupStage(cchar *name)
 Lookup a stage by name.
void*httpLookupStageData(cchar *name)
 Lookup stage data.
cchar*httpLookupStatus(int status)
 Lookup a Http status code.
HttpUser*httpLookupUser(HttpAuth *auth, cchar *name)
 Lookup a user by username.
char*httpMakePath(HttpRoute *route, cchar *dir, cchar *path)
 Make a filename path.
HttpUri*httpMakeUriLocal(HttpUri *uri)
 Make a URI local.
cchar*httpMapContent(HttpStream *stream, cchar *filename)
 Map a content filename.
voidhttpMapFile(HttpStream *stream)
 Map the request URI to a filename in physical storage for a handler.
struct HttpHost*httpMatchHost(HttpNet *net, cchar *hostname)
 Match the HttpHost object that should serve this request.
boolhttpMatchParam(HttpStream *stream, cchar *var, cchar *expected)
 Match a form variable with an expected value.
MprSsl*httpMatchSsl(MprSocket *sp, cchar *hostname)
 Match the HttpHost object that should serve this request.
voidhttpMemoryError(HttpStream *stream)
 Signal a memory allocation error in a response to the peer.
int64httpMonitorEvent(struct HttpStream *stream, int counter, int64 adj)
 Monitor an event and validate against defined limits and monitored resources.
int64httpMonitorNetEvent(struct HttpNet *net, int counter, int64 adj)
 Monitor a network event and validate against defined limits and monitored resources.
boolhttpNeedRetry(HttpStream *stream, cchar **url)
 Determine if the transmission needs a transparent retry to implement authentication or redirection.
voidhttpNetError(HttpNet *net, cchar *fmt, ...)
 Error handling for the network.
voidhttpNetTimeout(HttpNet *net)
 Schedule a network connection timeout event on a network.
boolhttpNextQueueFull(HttpQueue *q)
 Test if the next queue is full.
HttpUri*httpNormalizeUri(HttpUri *uri)
 Normalize a URI.
char*httpNormalizeUriPath(cchar *uri)
 Normalize a URI.
voidhttpNotify(HttpStream *stream, int event, int arg)
 Inform notifiers of a connection event or state change.
voidhttpOmitBody(HttpStream *stream)
 Tell the tx to omit sending any body.
boolhttpOption(MprHash *options, cchar *field, cchar *value, int useDefault)
 Test a field value from an option string.
voidhttpParseAll(HttpRoute *route, cchar *key, MprJson *prop)
 Parse all the properties under the given key.
inthttpParsePlatform(cchar *platform, cchar **os, cchar **arch, cchar **profile)
 Parse a platform string.
voidhttpProcess(HttpQueue *q)
 Process Http requests and responses.
boolhttpProcessHeaders(HttpQueue *q)
 Process Http headers.
voidhttpPutBackPacket(struct HttpQueue *q, HttpPacket *packet)
 Put a packet back onto a queue.
voidhttpPutForService(struct HttpQueue *q, HttpPacket *packet, bool serviceQ)
 Put a packet into the service queue for deferred processing.
voidhttpPutPacket(struct HttpQueue *q, HttpPacket *packet)
 Put a packet to the queue.
voidhttpPutPacketToNext(struct HttpQueue *q, HttpPacket *packet)
 Put a packet to the next queue downstream.
boolhttpQueuesNeedService(HttpNet *net)
 Test if the network queues need service.
ssizehttpRead(HttpStream *stream, char *buffer, ssize size)
 Read rx body data.
ssizehttpReadBlock(HttpStream *stream, char *buffer, ssize size, MprTicks timeout, int flags)
 Read a block of rx body data.
char*httpReadString(HttpStream *stream)
 Read response data as a string.
voidhttpReadyHandler(HttpStream *stream)
 Run the handler ready callback.
voidhttpRedirect(HttpStream *stream, int status, cchar *uri)
 Redirect the client.
voidhttpRemoveCookie(HttpStream *stream, cchar *name)
 Remove a cookie from the client (browser) This will emit a Set-Cookie response header with the value set to "" and a one second lifespan.
inthttpRemoveHeader(HttpStream *stream, cchar *key)
 Remove a header from the transmission.
voidhttpRemoveOption(MprHash *options, cchar *field)
 Remove an option.
voidhttpRemoveParam(HttpStream *stream, cchar *var)
 Remove a request param.
voidhttpRemoveQueue(HttpQueue *q)
 Remove a queue.
inthttpRemoveRole(HttpAuth *auth, cchar *role)
 Remove a role.
voidhttpRemoveRouteMethods(HttpRoute *route, cchar *methods)
 Remove HTTP methods for the route.
inthttpRemoveSessionVar(HttpStream *stream, cchar *name)
 Remove a session state variable.
inthttpRemoveUser(HttpAuth *auth, cchar *user)
 Remove a user.
HttpStream*httpRequest(cchar *method, cchar *uri, cchar *data, int protocol, char **err)
 Issue a http request.
boolhttpRequestExpired(HttpStream *stream, MprTicks timeout)
 Test if a request has exceeded its timeout limits.
voidhttpResetClientStream(HttpStream *stream, bool keepHeaders)
 Prepare a client connection for a new request.
voidhttpResetCredentials(HttpStream *stream)
 Reset the current security credentials.
voidhttpResetRouteIndexes(HttpRoute *route)
 Reset all defined indexes.
voidhttpResetRoutePipeline(HttpRoute *route)
 Reset the route pipeline.
voidhttpResetRoutes(HttpHost *host)
 Reset the list of routes for the host.
HttpPacket*httpResizePacket(struct HttpQueue *q, HttpPacket *packet, ssize size)
 Resize a packet.
HttpUri*httpResolveUri(struct HttpStream *stream, HttpUri *base, HttpUri *target)
 Resolve URIs relative to a base.
voidhttpResumeQueue(HttpQueue *q)
 Resume a queue.
voidhttpReturnNet(HttpNet *net)
 Return a borrowed a network connection.
voidhttpRouteRequest(HttpStream *stream)
 Route the request and select that matching route and handle to process the request.
voidhttpScheduleQueue(HttpQueue *q)
 Schedule a queue.
inthttpSecureEndpoint(HttpEndpoint *endpoint, struct MprSsl *ssl)
 Secure an endpoint.
inthttpSecureEndpointByName(cchar *name, struct MprSsl *ssl)
 Secure an endpoint by name.
ssizehttpSend(HttpStream *stream, cchar *fmt, ...) PRINTF_ATTRIBUTE(2
 Send a UTF-8 text message to the WebSocket peer.
ssizehttpSendBlock(HttpStream *stream, int type, cchar *msg, ssize len, int flags)
 Send a message of a given type to the WebSocket peer.
ssizehttpSendClose(HttpStream *stream, int status, cchar *reason)
 Send a close message to the WebSocket peer.
boolhttpServerStream(HttpStream *stream)
 Test if the connection is a server-side connection.
boolhttpServiceQueues(HttpNet *net, int flags)
 Service pipeline queues to flow data.
voidhttpSetAsync(HttpNet *net, bool async)
 Set the async mode value for the network.
voidhttpSetAuthAllow(HttpAuth *auth, cchar *ip)
 Allow access by a client IP IP address.
voidhttpSetAuthAnyValidUser(HttpAuth *auth)
 Allow access by any valid user.
voidhttpSetAuthDeny(HttpAuth *auth, cchar *ip)
 Deny access by a client IP address.
voidhttpSetAuthFormDetails(struct HttpRoute *route, cchar *loginPage, cchar *loginService, cchar *logoutService, cchar *loggedInPage, cchar *loggedOutPage)
 Define login service URLs for use with "form" authentication.
voidhttpSetAuthLogin(HttpAuth *auth, cchar *uri)
 Define the login page for use with authentication.
voidhttpSetAuthOrder(HttpAuth *auth, int order)
 Set the auth allow/deny order.
voidhttpSetAuthPermittedUsers(HttpAuth *auth, cchar *users)
 Define the set of permitted users.
voidhttpSetAuthQop(HttpAuth *auth, cchar *qop)
 Set the required quality of service for digest authentication.
voidhttpSetAuthRealm(HttpAuth *auth, cchar *realm)
 Set the required realm for basic or digest authentication.
voidhttpSetAuthRequiredAbilities(HttpAuth *auth, cchar *abilities)
 Set the required abilities for access.
voidhttpSetAuthSession(HttpAuth *auth, bool noSession)
 Control whether a session and session cookie will be created for user logins for this authentication route.
inthttpSetAuthStore(HttpAuth *auth, cchar *store)
 Set the authentication password store to use.
voidhttpSetAuthStoreSessions(HttpAuthStore *store, bool noSession)
 Control whether sessions and session cookies are created for user logins.
voidhttpSetAuthStoreVerify(HttpAuthStore *store, HttpVerifyUser verifyUser)
 Set the global verify callback for an authentication store.
inthttpSetAuthType(HttpAuth *auth, cchar *proto, cchar *details)
 Set the authentication protocol type to use.
voidhttpSetAuthUsername(HttpAuth *auth, cchar *username)
 Set an automatic login username.
voidhttpSetAuthVerify(HttpAuth *auth, HttpVerifyUser verifyUser)
 Set the verify callback for an authentication object that is part of a route.
voidhttpSetChunkSize(HttpStream *stream, ssize size)
 Set the chunk size for transfer chunked encoding.
voidhttpSetContentLength(HttpStream *stream, MprOff length)
 Define a content length header in the transmission.
voidhttpSetContentType(HttpStream *stream, cchar *mimeType)
 Set the transmission (response) content mime type.
voidhttpSetContext(void *context)
 Set the http context object.
voidhttpSetCookie(HttpStream *stream, cchar *name, cchar *value, cchar *path, cchar *domain, MprTicks lifespan, int flags)
 Set a transmission cookie.
voidhttpSetCredentials(HttpStream *stream, cchar *user, cchar *password, cchar *authType)
 Set the Http credentials.
voidhttpSetDefaultClientHost(cchar *host)
 Define a default client host.
voidhttpSetDefaultClientPort(int port)
 Define a default client port.
voidhttpSetDefaultHost(HttpHost *host)
 Set the default host for all servers.
voidhttpSetDir(HttpRoute *route, cchar *name, cchar *value)
 Define a route directory path variable.
inthttpSetEndpointAddress(HttpEndpoint *endpoint, cchar *ip, int port)
 Set the endpoint IP address.
voidhttpSetEndpointAsync(HttpEndpoint *endpoint, int enable)
 Control if the endpoint is running in asynchronous mode.
voidhttpSetEndpointContext(HttpEndpoint *endpoint, void *context)
 Set the endpoint context object.
voidhttpSetEndpointNotifier(HttpEndpoint *endpoint, HttpNotifier fn)
 Define a notifier callback for this endpoint.
voidhttpSetEof(HttpStream *stream)
 Set the HttpRx eof condition.
voidhttpSetFileHandler(HttpStream *stream, cchar *path)
 Set the "fileHandler" to process the request.
boolhttpSetFilename(HttpStream *stream, cchar *filename, int flags)
 Set the filename to serve for a request.
voidhttpSetForkCallback(MprForkCallback proc, void *arg)
 Set the fork callback.
inthttpSetGroupAccount(cchar *group)
 Set the group account.
voidhttpSetHandler(HttpStream *stream, HttpStage *handler)
 Set the handler for this request Use this request from the Handler rewrite callback to change the selected handler to process a request.
voidhttpSetHeader(HttpStream *stream, cchar *key, cchar *fmt, ...) PRINTF_ATTRIBUTE(3
 Set a transmission header.
void voidhttpSetHeaderString(HttpStream *stream, cchar *key, cchar *value)
 Set a simple key/value transmission header.
voidhttpSetHeadersCallback(struct HttpStream *stream, HttpHeadersCallback fn, void *arg)
 Define a headers callback.
inthttpSetHostCanonicalName(HttpHost *host, cchar *name)
 Set the host canonical name.
voidhttpSetHostDefaultEndpoint(HttpHost *host, HttpEndpoint *endpoint)
 Set the default endpoint for a host.
voidhttpSetHostDefaultRoute(HttpHost *host, HttpRoute *route)
 Set the default route for a host.
inthttpSetHostName(HttpHost *host, cchar *name)
 Set the host name.
voidhttpSetHostProtocol(HttpHost *host, cchar *protocol)
 Set the host HTTP protocol version.
voidhttpSetHostRoot(HttpHost *host, cchar *root)
 Set the server root for a host.
voidhttpSetHostSecureEndpoint(HttpHost *host, HttpEndpoint *endpoint)
 Set the default secure endpoint for a host.
voidhttpSetIOCallback(struct HttpNet *net, HttpIOCallback fn)
 Define an I/O callback for network connections.
voidhttpSetIntParam(HttpStream *stream, cchar *var, int value)
 Set an integer request param value.
voidhttpSetKeepAliveCount(HttpStream *stream, int count)
 Control Http Keep-Alive for the connection.
voidhttpSetMethod(HttpStream *stream, cchar *method)
 Set a new HTTP method for processing.
voidhttpSetNetContext(HttpNet *net, void *context)
 Set the network context object.
voidhttpSetNetProtocol(HttpNet *net, int protocol)
 Set the Http protocol variant for this network connection.
voidhttpSetOption(MprHash *options, cchar *field, cchar *value)
 Set an option.
voidhttpSetParam(HttpStream *stream, cchar *var, cchar *value)
 Set a request param value.
inthttpSetPlatform(cchar *platform)
 Set platform description.
inthttpSetPlatformDir(cchar *platform)
 Set platform directory location.
voidhttpSetProxy(cchar *host, int port)
 Define a Http proxy host to use for all client connect requests.
voidhttpSetQueueLimits(HttpQueue *q, HttpLimits *limits, ssize packetSize, ssize low, ssize max, ssize window)
 Set a queue's max packetSize and flow control low, max and window thresholds.
voidhttpSetRequestCallback(HttpRequestCallback callback)
 Define a request completion callback.
voidhttpSetResponded(HttpStream *stream)
 Set the responded flag for the request.
voidhttpSetRouteAuth(HttpRoute *route, HttpAuth *auth)
 Set the route authentication.
voidhttpSetRouteAutoDelete(HttpRoute *route, bool on)
 Control file upload auto delete.
voidhttpSetRouteCompile(HttpRoute *route, bool on)
 Define whether updating a request may compile from source.
inthttpSetRouteConnector(HttpRoute *route, cchar *name)
 Set the connector to use for a route.
voidhttpSetRouteCookie(HttpRoute *route, cchar *cookie)
 Set the route session cookie.
voidhttpSetRouteCookiePersist(HttpRoute *route, int enable)
 Persist the cookie to disk.
voidhttpSetRouteData(HttpRoute *route, cchar *key, void *data)
 Set route data.
voidhttpSetRouteDefaultLanguage(HttpRoute *route, cchar *language)
 Set the default language for the route.
voidhttpSetRouteDocuments(HttpRoute *route, cchar *path)
 Set the route directory.
voidhttpSetRouteEnvEscape(HttpRoute *route, bool on)
 Define whether shell special characters are escaped in environment variables.
voidhttpSetRouteEnvPrefix(HttpRoute *route, cchar *prefix)
 Define a prefix string for environment variables.
voidhttpSetRouteFlags(HttpRoute *route, int flags)
 Update the route flags.
inthttpSetRouteHandler(HttpRoute *route, cchar *name)
 Set the handler to use for a route.
voidhttpSetRouteHome(HttpRoute *route, cchar *home)
 Set the route directory for configuration files.
voidhttpSetRouteIgnoreEncodingErrors(HttpRoute *route, bool on)
 Set the route to ignore UTF encoding errors for WebSocket connections.
voidhttpSetRouteMethods(HttpRoute *route, cchar *methods)
 Define the methods for the route.
voidhttpSetRoutePattern(HttpRoute *route, cchar *pattern, int flags)
 Set the route pattern.
voidhttpSetRoutePrefix(HttpRoute *route, cchar *prefix)
 Set the route prefix.
voidhttpSetRoutePreserveFrames(HttpRoute *route, bool on)
 Set the route to preserve WebSocket frames boundaries.
voidhttpSetRouteRenameUploads(HttpRoute *route, bool enable)
 Control the renaming of uploaded filenames.
voidhttpSetRouteScript(HttpRoute *route, cchar *script, cchar *scriptPath)
 Set the script to service the route.
voidhttpSetRouteSessionVisibility(HttpRoute *route, bool visible)
 Make session cookies that are visible to javascript.
voidhttpSetRouteShowErrors(HttpRoute *route, bool on)
 Define whether to show errors to the client.
voidhttpSetRouteSource(HttpRoute *route, cchar *source)
 Set the source code module for the route.
voidhttpSetRouteStealth(HttpRoute *route, bool on)
 Set stealth mode for the route.
inthttpSetRouteTarget(HttpRoute *route, cchar *name, cchar *details)
 Set a route target.
voidhttpSetRouteTemplate(HttpRoute *route, cchar *tplate)
 Set the route template.
voidhttpSetRouteUpdate(HttpRoute *route, bool on)
 Define whether updating a cached request is required.
voidhttpSetRouteUploadDir(HttpRoute *route, cchar *dir)
 Set the default upload directory for file uploads.
voidhttpSetRouteVar(HttpRoute *route, cchar *token, cchar *value)
 Define a route variable.
voidhttpSetRouteWorkers(HttpRoute *route, int workers)
 Define the maximum number of workers for a route.
voidhttpSetRouteXsrf(HttpRoute *route, bool enable)
 Control whether an XSRF token will be emitted during a user login sequence.
voidhttpSetSessionNotify(MprCacheProc notifyProc)
 Set a notification callback to be invoked for session notification events.
inthttpSetSessionObj(HttpStream *stream, cchar *key, MprHash *value)
 Set an object into the session state store.
inthttpSetSessionVar(HttpStream *stream, cchar *name, cchar *value)
 Set a session variable.
voidhttpSetSoftware(cchar *description)
 Set the software description.
voidhttpSetStageData(struct HttpStream *stream, cchar *key, cvoid *data)
 Set stage data.
voidhttpSetState(HttpStream *stream, int state)
 Set the connection state and invoke notifiers.
voidhttpSetStatus(HttpStream *stream, int status)
 Set a Http response status.
voidhttpSetStreamContext(HttpStream *stream, void *context)
 Set the connection context object.
voidhttpSetStreamData(HttpStream *stream, void *data)
 Set the connection data field.
voidhttpSetStreamHost(HttpStream *stream, void *host)
 Set the connection host object.
voidhttpSetStreamNotifier(HttpStream *stream, HttpNotifier notifier)
 Define a notifier callback for this connection.
voidhttpSetStreamUser(HttpStream *stream, struct HttpUser *user)
 Set the logged in user associated with the connection.
voidhttpSetStreaming(struct HttpHost *host, cchar *mime, cchar *uri, bool streaming)
 Control if input body content should be streamed or buffered for requests with content of a given mime type.
voidhttpSetTimeout(HttpStream *stream, MprTicks requestTimeout, MprTicks inactivityTimeout)
 Set the Http inactivity timeout.
voidhttpSetTimestamp(MprTicks period)
 Define a timestamp in the MPR log file.
voidhttpSetTraceContentSize(HttpTrace *trace, ssize size)
 Set the maximum content size to trace.
voidhttpSetTraceEventLevel(HttpTrace *trace, cchar *type, int level)
 Configure the tracing level for an event type.
voidhttpSetTraceFormat(HttpTrace *trace, cchar *format)
 Set the logging format.
HttpTraceFormatterhttpSetTraceFormatter(HttpTrace *trace, HttpTraceFormatter callback)
 Set the formatter callback to use with a trace object.
voidhttpSetTraceFormatterName(HttpTrace *trace, cchar *name)
 Define the trace formatter by name.
voidhttpSetTraceLevel(int level)
 Set the current tracing verbosity level.
inthttpSetTraceLogFile(HttpTrace *trace, cchar *path, ssize size, int backup, cchar *format, int flags)
 Configure the request trace log.
voidhttpSetTraceLogger(HttpTrace *trace, HttpTraceLogger callback)
 Set the trace callback to use with a trace object.
inthttpSetUri(HttpStream *stream, cchar *uri)
 Set a new URI for processing.
inthttpSetUserAccount(cchar *user)
 Set the user account.
voidhttpSetWebSocketData(HttpStream *stream, void *data)
 Set the WebSocket private data.
voidhttpSetWebSocketPreserveFrames(HttpStream *stream, bool on)
 Preserve frames for incoming messages.
voidhttpSetWebSocketProtocols(HttpStream *stream, cchar *protocols)
 Set a list of application-level protocols supported by the client.
boolhttpShouldRenderDirListing(HttpStream *stream)
 Test if a directory listing should be rendered for the request.
voidhttpSimpleTraceFormatter(HttpTrace *trace, cchar *event, cchar *type, int flags, cchar *buf, ssize len, cchar *fmt, va_list args)
 Simple log trace formatter for debugging.
HttpPacket*httpSplitPacket(HttpPacket *packet, ssize offset)
 Split a data packet.
inthttpStartEndpoint(HttpEndpoint *endpoint)
 Start listening for client connections on an endpoint.
inthttpStartEndpoints(void)
 Start listening for client connections on all endpoints.
voidhttpStartPipeline(HttpStream *stream)
 Start the pipeline.
inthttpStartTracing(cchar *traceSpec)
 Start tracing for the given trace log file when instructed via a command line switch.
char*httpStatsReport(int flags)
 Get an Http performance report.
MprSocket*httpStealSocket(HttpNet *net)
 Steal a socket from a network.
SockethttpStealSocketHandle(HttpNet *net)
 Steal the O/S socket handle from the network socket object.
voidhttpStopEndpoint(HttpEndpoint *endpoint)
 Stop the server listening for client connections.
voidhttpStopEndpoints(void)
 Stop listening for client connections on all endpoints.
voidhttpStreamTimeout(HttpStream *stream)
 Schedule a connection timeout event on a connection.
voidhttpSuspendQueue(HttpQueue *q)
 Suspend a queue.
char*httpTemplate(HttpStream *stream, cchar *tplate, MprHash *options)
 Expand a template string using given options.
inthttpTestParam(HttpStream *stream, cchar *var)
 Test if a request param is defined.
boolhttpTokenize(HttpRoute *route, cchar *str, cchar *fmt, ...)
 Tokenize a string based on route data.
boolhttpTokenizev(HttpRoute *route, cchar *str, cchar *fmt, va_list args)
 Tokenize a string based on route data.
boolhttpTrace(HttpTrace *trace, cchar *event, cchar *type, cchar *fmt, ...)
 Trace an event of interest.
bool boolhttpTraceData(HttpTrace *trace, cchar *event, cchar *type, int flags, cchar *buf, ssize len, cchar *fmt, ...) PRINTF_ATTRIBUTE(7
 Trace with data buffer.
bool bool,boolhttpTracePacket(HttpTrace *trace, cchar *event, cchar *type, int flags, struct HttpPacket *packet, cchar *values, ...) PRINTF_ATTRIBUTE(6
 Trace request packet.
voidhttpTrimExtraPath(HttpStream *stream)
 Trim extra path from the URI.
ssizehttpUpdateCache(HttpStream *stream, cchar *uri, cchar *data, MprTicks lifespan)
 Update the cached content for a URI.
inthttpUpgradeWebSocket(HttpStream *stream)
 Upgrade a client HTTP connection connection to use WebSockets.
char*httpUriToString(HttpUri *uri, int flags)
 Convert a Uri to a string.
boolhttpValidUriChars(cchar *uri)
 Test if a URI is using only valid characters Note this does not test if the URI is fully legal.
char*httpValidateUriPath(cchar *uri)
 Validate a URI path as expected in a HTTP request line.
boolhttpVerifyWebSocketsHandshake(HttpStream *stream)
 Verify the server handshake.
inthttpWait(HttpStream *stream, int state, MprTicks timeout)
 Wait for the client connection to achieve the requested state.
boolhttpWebSocketOrderlyClosed(HttpStream *stream)
 Test if WebSocket connection was orderly closed by sending an acknowledged close message.
boolhttpWillNextQueueAcceptPacket(HttpQueue *q, HttpPacket *packet)
 Determine if the downstream queue will accept this packet.
boolhttpWillNextQueueAcceptSize(HttpQueue *q, ssize size)
 Determine if the downstream queue will accept a certain amount of data.
boolhttpWillQueueAcceptPacket(HttpQueue *q, HttpQueue *nextQ, HttpPacket *packet)
 Determine if the given queue will accept this packet.
ssizehttpWrite(HttpQueue *q, cchar *fmt, ...) PRINTF_ATTRIBUTE(2
 Write a formatted string.
ssizehttpWriteBlock(HttpQueue *q, cchar *buf, ssize size, int flags)
 Write a block of data to the queue.
ssizehttpWriteCached(HttpStream *stream)
 Write the cached content for a URI to the client.
inthttpWriteSession(HttpStream *stream)
 Write the session state to persistent data storage.
ssizehttpWriteString(HttpQueue *q, cchar *s)
 Write a string of data to the queue.
bool bool,bool,voidhttpWriteTrace(HttpTrace *trace, cchar *buf, ssize len)
 Convenience routine to write trace to the trace logger.
voidhttpWriteTraceLogFile(HttpTrace *trace, cchar *buf, ssize len)
 Write a message to the trace file logger.
ssizehttpWriteUploadData(HttpStream *stream, MprList *formData, MprList *fileData)
 Write Http upload body data.

Typedefs

HttpAddressPer-IP address structure.
HttpAskLoginAuthType callback to generate a response requesting the user login This should call httpError if such a response cannot be generated.
HttpAuthStorePassword backend store.
HttpAuthTypeAuthentication Protocol.
HttpConfigureProcCallback procedure for HttpConfigure.
HttpCounterMonitoring counter.
HttpDefenseMonitor defense configuration.
HttpEnvCallbackSet environment vars callback.
HttpFillProcCallback procedure to fill a packet with data.
HttpHeaderTableHTTP HPACK header table.
HttpHeadersCallbackCallback to fill headers.
HttpIOCallbackI/O callback for network connections.
HttpLangLanguage definition record for routes.
HttpListenCallbackListen callback.
HttpNotifierHttpStream state change notification callback.
HttpParseAuthAuthType callback to parse the HTTP 'Authorize' (client) and 'www-authenticate' (server) headers.
HttpParseCallbackHttp JSON configuration parse callback.
HttpRemedyProcDefense remedy callback.
HttpRequestCallbackRequest completion callback.
HttpRoleAuthorization Roles.
HttpRouteOpRoute operation record.
HttpRouteProcGeneral route procedure.
HttpRouteSetProcRouteSet callback.
HttpSetAuthAuthType callback to set the necessary HTTP authorization headers for a client request.
HttpTimeoutCallbackTimeout callback.
HttpTraceFormatterTrace formatter callback.
HttpTraceLoggerTrace logger callback.
HttpUserUser Authorization.
HttpVerifyUserAuthStore callback Verify the user credentials.

Defines

#defineHTTP2_DEFAULT_WEIGHT   16
 Unused.
#defineHTTP2_FRAME_OVERHEAD   9
 Minimum HTTP/2 frame size.
#defineHTTP2_GOAWAY_SIZE   8
 Size of goaway frame data.
#defineHTTP2_HEADER_OVERHEAD   32
 HPACK table overhead by spec.
#defineHTTP2_MAX_FRAME_SIZE   ((1 << 24) - 1)
 Maximum frame size by spec.
#defineHTTP2_MAX_STREAM   ((1U << 31) - 1)
 Maximum stream number by spec.
#defineHTTP2_MAX_WINDOW   ((1U << 31) - 1)
 Maximum window size by spec.
#defineHTTP2_MIN_FRAME_SIZE   (16 * 1024)
 Default and minimum frame size - modified by config.
#defineHTTP2_MIN_WINDOW   65535
 Initial default window size by spec.
#defineHTTP2_RESET_SIZE   4
 Size of rest frame data.
#defineHTTP2_SETTINGS_SIZE   6
 Size of settings frame data.
#defineHTTP2_WINDOW_SIZE   4
 Size of windows frame data.
#defineHTTP_ADDED_BODY_PARAMS   0x800
 Body data added to params.
#defineHTTP_ADDED_QUERY_PARAMS   0x400
 Query added to params.
#defineHTTP_ALLOW_DENY   0x1
 Run allow checks before deny checks.
#defineHTTP_AUTH_NO_SESSION   0x4
 Do not create a session when authenticated.
#defineHTTP_AUTH_TYPE_CONDITION   0x1
 Use auth condition.
#defineHTTP_BLOCK   0x1
 Flag for httpSendBlock and httpWriteBlock to indicate blocking operation.
#defineHTTP_BUFFER   0x4
 Flag for httpSendBlock and httpWriteBlock to always absorb the data without blocking.
#defineHTTP_CACHE_CLIENT   0x1
 Cache on the client side.
#defineHTTP_CACHE_HAS_PARAMS   0x20
 Cache definition has params.
#defineHTTP_CACHE_MANUAL   0x4
 Cache manually.
#defineHTTP_CACHE_RESET   0x8
 Don't inherit cache config from outer routes.
#defineHTTP_CACHE_SERVER   0x2
 Cache on the server side.
#defineHTTP_CACHE_STATIC   0x40
 Cache extensions: css, gif, ico, jpg, js, html, pdf, ttf, txt, xml, woff.
#defineHTTP_CACHE_UNIQUE   0x10
 Uniquely cache request with different params.
#defineHTTP_CHUNK_DATA   2
 Start of chunk data.
#defineHTTP_CHUNK_EOF   3
 End of last chunk.
#defineHTTP_CHUNK_START   1
 Start of a new chunk.
#defineHTTP_CHUNK_UNCHUNKED   0
 Data is not transfer-chunk encoded.
#defineHTTP_CHUNKED   0x200
 Content is chunk encoded.
#defineHTTP_CLIENT_SIDE   0x1
 Initialize the client-side support.
#defineHTTP_CODE_ACCEPTED   202
 The request has been accepted and processing is continuing.
#defineHTTP_CODE_BAD_GATEWAY   502
 The server cannot act as a gateway for the given request.
#defineHTTP_CODE_BAD_HANDSHAKE   551
 The server handsake response is unacceptable.
#defineHTTP_CODE_BAD_METHOD   405
 The request HTTP method was not supported by the resource.
#defineHTTP_CODE_BAD_REQUEST   400
 The request is malformed.
#defineHTTP_CODE_BAD_VERSION   505
 The server does not support the HTTP protocol version.
#defineHTTP_CODE_CERT_ERROR   495
 The peer provided certificate is unacceptable.
#defineHTTP_CODE_CLIENT_ERROR   552
 The server responded, but the response is unacceptable to the client.
#defineHTTP_CODE_COMMS_ERROR   550
 The server had a communications error responding to the client.
#defineHTTP_CODE_CONFLICT   409
 The request had a conflict in the request headers and URI.
#defineHTTP_CODE_CONTINUE   100
 Continue with request, only partial content transmitted.
#defineHTTP_CODE_CREATED   201
 The request has completed and a new resource was created.
#defineHTTP_CODE_EXPECTATION_FAILED   417
 The server cannot satisfy the Expect header requirements.
#defineHTTP_CODE_FORBIDDEN   403
 The request was legal, but the server refuses to process.
#defineHTTP_CODE_GATEWAY_TIMEOUT   504
 The server gateway timed out waiting for the upstream server.
#defineHTTP_CODE_GONE   410
 The requested resource is no longer available.
#defineHTTP_CODE_IM_A_TEAPOT   418
 Short and stout error code (RFC 2324).
#defineHTTP_CODE_INSUFFICIENT_STORAGE   507
 The server has insufficient storage to complete the request.
#defineHTTP_CODE_INTERNAL_SERVER_ERROR   500
 Server processing or configuration error.
#defineHTTP_CODE_LENGTH_REQUIRED   411
 The request did not specify a required content length.
#defineHTTP_CODE_MOVED_PERMANENTLY   301
 The requested URI has moved permanently to a new location.
#defineHTTP_CODE_MOVED_TEMPORARILY   302
 The URI has moved temporarily to a new location.
#defineHTTP_CODE_NO_CONTENT   204
 The request has completed and there is no response to send.
#defineHTTP_CODE_NO_RESPONSE   444
 The connection was closed with no response to the client.
#defineHTTP_CODE_NOT_ACCEPTABLE   406
 The requested resource cannot generate the required content.
#defineHTTP_CODE_NOT_AUTHORITATIVE   203
 The request has completed but content may be from another source.
#defineHTTP_CODE_NOT_FOUND   404
 The requested resource was not found.
#defineHTTP_CODE_NOT_IMPLEMENTED   501
 The server does not recognize the request or method.
#defineHTTP_CODE_NOT_MODIFIED   304
 The requested resource has changed since the last request.
#defineHTTP_CODE_OK   200
 The request completed successfully.
#defineHTTP_CODE_PARTIAL   206
 The request has completed and is returning partial content.
#defineHTTP_CODE_PAYMENT_REQUIRED   402
 Reserved for future use.
#defineHTTP_CODE_PRECOND_FAILED   412
 The server cannot satisfy one of the request preconditions.
#defineHTTP_CODE_RANGE_NOT_SATISFIABLE   416
 The request content range does not exist for the resource.
#defineHTTP_CODE_REQUEST_TIMEOUT   408
 The server timed out waiting for the request to complete.
#defineHTTP_CODE_REQUEST_TOO_LARGE   413
 The request is too large for the server to process.
#defineHTTP_CODE_REQUEST_URL_TOO_LARGE   414
 The request URI is too long for the server to process.
#defineHTTP_CODE_RESET   205
 The request has completed with no content.
#defineHTTP_CODE_SEE_OTHER   303
 The requested URI can be found at another URI location.
#defineHTTP_CODE_SERVICE_UNAVAILABLE   503
 The server is currently unavailable or overloaded.
#defineHTTP_CODE_SWITCHING   101
 Switching protocols.
#defineHTTP_CODE_TEMPORARY_REDIRECT   307
 The request should be repeated at another URI location.
#defineHTTP_CODE_UNAUTHORIZED   401
 Authentication for the request has failed.
#defineHTTP_CODE_UNSUPPORTED_MEDIA_TYPE   415
 The request media type is not supported by the server or resource.
#defineHTTP_CODE_USE_PROXY   305
 The requested resource must be accessed via the location proxy.
#defineHTTP_COMPLETE_URI   0x1
 Complete all missing URI fields.
#defineHTTP_COMPLETE_URI_PATH   0x2
 Complete missing URI path.
#defineHTTP_COOKIE_HTTP   0x2
 Flag for Set-Cookie httponly.
#defineHTTP_COOKIE_SAME_LAX   0x4
 Flag for Set-Cookie SameSite=Lax.
#defineHTTP_COOKIE_SAME_STRICT   0x8
 Flag for Set-Cookie SameSite=Strict.
#defineHTTP_COOKIE_SECURE   0x1
 Flag for Set-Cookie for SSL only.
#defineHTTP_COUNTER_ACTIVE_CLIENTS   0
 Active unique client IP addresses.
#defineHTTP_COUNTER_ACTIVE_CONNECTIONS   1
 Active connections per client.
#defineHTTP_COUNTER_ACTIVE_PROCESSES   3
 Total processes for server.
#defineHTTP_COUNTER_ACTIVE_REQUESTS   2
 Active requests per client.
#defineHTTP_COUNTER_BAD_REQUEST_ERRORS   4
 Bad request format errors.
#defineHTTP_COUNTER_ERRORS   5
 All errors.
#defineHTTP_COUNTER_LIMIT_ERRORS   6
 Limit violation errors.
#defineHTTP_COUNTER_MAX   12
 Max standard counters.
#defineHTTP_COUNTER_MEMORY   7
 Total application memory for server.
#defineHTTP_COUNTER_NETWORK_IO   8
 Network I/O.
#defineHTTP_COUNTER_NOT_FOUND_ERRORS   9
 URI not found errors.
#defineHTTP_COUNTER_REQUESTS   10
 Request count.
#defineHTTP_COUNTER_SSL_ERRORS   11
 SSL upgrade errors.
#defineHTTP_CREATE_ENV   0x80
 Must create env for this request.
#defineHTTP_DELAY_SERVICE   0
 Delay servicing the queue.
#defineHTTP_DELETE   0x1
 DELETE method.
#defineHTTP_DENY_ALLOW   0x2
 Run deny checks before allow checks.
#defineHTTP_EVENT_APP_CLOSE   6
 The request is now closed.
#defineHTTP_EVENT_DESTROY   5
 The HttpStream object is being closed and destroyed.
#defineHTTP_EVENT_ERROR   4
 The request has an error.
#defineHTTP_EVENT_MAX   8
 Maximum event plus one.
#defineHTTP_EVENT_READABLE   2
 The request has data available for reading.
#defineHTTP_EVENT_STATE   1
 Notifier events.
#defineHTTP_EVENT_WRITABLE   3
 The request is now writable (post / put data).
#defineHTTP_EXPECT_CONTINUE   0x1000
 Client expects an HTTP 100 Continue response.
#defineHTTP_GET   0x2
 GET method.
#defineHTTP_HEAD   0x4
 HEAD method.
#defineHTTP_HOST_ATTACHED   0x100
 Host name attached to an endpoint.
#defineHTTP_HOST_NO_TRACE   0x10
 Host flag to disable the of TRACE HTTP method.
#defineHTTP_HOST_WILD_CONTAINS   0x40
 Host name contains the host name.
#defineHTTP_HOST_WILD_REGEXP   0x80
 Host name is a regular expression.
#defineHTTP_HOST_WILD_STARTS   0x20
 Host name starts with pattern.
#defineHTTP_IF_MODIFIED   0x100
 If-[un]modified-since supplied.
#defineHTTP_LANG_AFTER   0x2
 Insert suffix after extension.
#defineHTTP_LANG_BEFORE   0x1
 Insert suffix before extension.
#defineHTTP_MAX_QUEUE   2
 Number of queue types.
#defineHTTP_MAX_SECRET   16
 Size of secret data for auth.
#defineHTTP_MORE   0x1000
 Flag for httpSendBlock to indicate there are more frames for this message.
#defineHTTP_NEW_DISPATCHER   0x1
 New dispatcher for each connection.
#defineHTTP_NON_BLOCK   0x2
 Flag for httpSendBlock and httpWriteBlock to indicate non-blocking operation.
#defineHTTP_OPTIONS   0x8
 OPTIONS method.
#defineHTTP_PACKET_DATA   0x4
 Packet contains actual content data.
#defineHTTP_PACKET_END   0x8
 End of stream packet.
#defineHTTP_PACKET_HEADER   0x1
 Packet contains HTTP headers.
#defineHTTP_PACKET_RANGE   0x2
 Packet is a range boundary packet.
#defineHTTP_PACKET_SOLO   0x10
 Don't join this packet.
#defineHTTP_POST   0x10
 Post method.
#defineHTTP_PUT   0x20
 PUT method.
#defineHTTP_QUEUE_ALL   0x8
 Queue has all the data there is and will be.
#defineHTTP_QUEUE_EOF   0x20
 Queue at end of data.
#defineHTTP_QUEUE_OPEN_TRIED   0x1
 Queue's open routine has been called.
#defineHTTP_QUEUE_OPENED   0x2
 Queue's open routine has been called.
#defineHTTP_QUEUE_OUTGOING   0x200
 Queue is for outgoing traffic.
#defineHTTP_QUEUE_READY   0x80
 Handler stage ready routine called.
#defineHTTP_QUEUE_REQUEST   0x400
 Queue is specific for this request.
#defineHTTP_QUEUE_RESERVICE   0x100
 Queue requires reservicing.
#defineHTTP_QUEUE_RX   1
 Receive (read from client) queue.
#defineHTTP_QUEUE_SERVICED   0x10
 Queue has been serviced at least once.
#defineHTTP_QUEUE_STARTED   0x40
 Handler stage start routine called.
#defineHTTP_QUEUE_SUSPENDED   0x4
 Queue's service routine is suspended due to flow control.
#defineHTTP_QUEUE_TX   0
 Send (transmit to client) queue.
#defineHTTP_ROUTE_CORS   0x40
 Cross-Origin resource sharing.
#defineHTTP_ROUTE_DOTNET_DIGEST_FIX   0x2000
 NET digest auth omits query in MD5.
#defineHTTP_ROUTE_ENV_ESCAPE   0x1000
 Escape env vars.
#defineHTTP_ROUTE_FREE   0x2
 Free Route.mdata back to malloc when route is freed.
#defineHTTP_ROUTE_FREE_PATTERN   0x4
 Free Route.patternCompiled back to malloc when route is freed.
#defineHTTP_ROUTE_HIDDEN   0x800
 Hide this route in route tables.
#defineHTTP_ROUTE_HOSTED   0x10000
 Route being hosted (appweb).
#defineHTTP_ROUTE_NO_LISTEN   0x20000
 Not listening on endpoints.
#defineHTTP_ROUTE_NOT   0x1
 Negate the route pattern test result.
#defineHTTP_ROUTE_OK   0
 The route matches the request.
#defineHTTP_ROUTE_OMIT_FILTER   1
 Omit filter.
#defineHTTP_ROUTE_OWN_LISTEN   0x80000
 Override listening endpoints.
#defineHTTP_ROUTE_PERSIST_COOKIE   0x40000
 Persist session cookie to disk.
#defineHTTP_ROUTE_PRESERVE_FRAMES   0x400
 Preserve WebSocket frame boundaries.
#defineHTTP_ROUTE_RAW   0x8
 Don't html encode the write data.
#defineHTTP_ROUTE_REDIRECT   0x4000
 Redirect secureCondition.
#defineHTTP_ROUTE_REJECT   1
 The route does not match the request.
#defineHTTP_ROUTE_REROUTE   2
 Request has been modified and must be re-routed.
#defineHTTP_ROUTE_SHOW_ERRORS   0x100
 Show errors to the client.
#defineHTTP_ROUTE_STARTED   0x10
 Route initialized.
#defineHTTP_ROUTE_STEALTH   0x80
 Stealth mode.
#defineHTTP_ROUTE_STRICT_TLS   0x8000
 Emit Strict-Transport-Security header.
#defineHTTP_ROUTE_UTILITY   0x100000
 Route hosted by a utility.
#defineHTTP_ROUTE_VISIBLE_SESSION   0x200
 Create a session cookie visible to client Javascript.
#defineHTTP_ROUTE_XSRF   0x20
 Generate XSRF tokens.
#defineHTTP_SCHEDULE_QUEUE   1
 Schedule the queue for service.
#defineHTTP_SERVER_SIDE   0x2
 Initialize the server-side support.
#defineHTTP_SESSION_COOKIE   "-http-session-"
 Session cookie name.
#defineHTTP_SESSION_IP   "__IP__"
 Connection IP address - prevents session hijack.
#defineHTTP_SESSION_USERNAME   "__USERNAME__"
 Username variable.
#defineHTTP_STAGE_AUTO_DIR   0x10000
 Want auto directory redirection.
#defineHTTP_STAGE_CONNECTOR   0x1000
 Stage is a connector.
#defineHTTP_STAGE_FILTER   0x4000
 Stage is a filter.
#defineHTTP_STAGE_HANDLER   0x2000
 Stage is a handler.
#defineHTTP_STAGE_INTERNAL   0x100000
 Internal stage - hidden.
#defineHTTP_STAGE_MODULE   0x8000
 Stage is a filter.
#defineHTTP_STAGE_RX   0x40000
 Stage to be used in the Rx direction.
#defineHTTP_STAGE_TX   0x80000
 Stage to be used in the Tx direction.
#defineHTTP_STAGE_UNLOADED   0x20000
 Stage module library has been unloaded.
#defineHTTP_STATE_BEGIN   1
 Ready for a new request.
#defineHTTP_STATE_COMPLETE   9
 Request complete.
#defineHTTP_STATE_CONNECTED   2
 Connection received or made.
#defineHTTP_STATE_CONTENT   5
 Reading posted content.
#defineHTTP_STATE_FINALIZED   8
 Input received, request processed and response transmitted.
#defineHTTP_STATE_FIRST   3
 First request line has been parsed.
#defineHTTP_STATE_PARSED   4
 Headers have been parsed, handler can start.
#defineHTTP_STATE_READY   6
 Handler ready - all body data received.
#defineHTTP_STATE_RUNNING   7
 Handler running.
#defineHTTP_TIMER_PERIOD   1000
 HttpTimer checks ever 1 second.
#defineHTTP_TRACE   0x40
 TRACE method.
#defineHTTP_TRACE_HEX   0x2
 Format content in hex with side ascii.
#defineHTTP_TRACE_MAX_SIZE   (10 * 1024)
 Default maximum body size to trace.
#defineHTTP_TRACE_MIN_LOG_SIZE   (10 * 1024)
 Minimum log file size.
#defineHTTP_TRACE_PACKET   0x1
 Trace a packet.
#defineHTTP_TX_HAS_FILTERS   0x100
 Has output filters.
#defineHTTP_TX_HEADERS_CREATED   0x2
 Response headers have been created.
#defineHTTP_TX_NO_BODY   0x1
 No transmission body, only send headers.
#defineHTTP_TX_NO_CHECK   0x10
 Do not check if the filename is inside the route documents directory.
#defineHTTP_TX_NO_LENGTH   0x20
 Do not emit a content length (used for TRACE).
#defineHTTP_TX_NO_MAP   0x40
 Do not map the filename to compressed or minified alternatives.
#defineHTTP_TX_PIPELINE   0x80
 Created Tx pipeline.
#defineHTTP_TX_USE_OWN_HEADERS   0x8
 Skip adding default headers.
#definehttpIsClient   (net && !net->endpoint)
 Test if the network is a client-side network.
#definehttpIsServer   (net && net->endpoint)
 Test if the network is a server-side network.
#defineME_HTTP_BAN_PERIOD   (5 * 60 * 1000)
 Default ban IP period.
#defineME_HTTP_DEFAULT_METHODS   "GET,POST"
 Default methods for routes.
#defineME_HTTP_DELAY   (2000)
 2 second delay per request - while delay enforced.
#defineME_HTTP_DELAY_PERIOD   (5 * 60 * 1000)
 Default delay IP period.
#defineME_HTTP_MONITOR_PERIOD   (15 * 1000)
 Monitor prune period.
#defineME_HTTP_REMEDY_TIMEOUT   (60 * 1000)
 Default remedy command timeout.
#defineME_HTTP_SOFTWARE   "Embedthis-http"
 Default Http protocol name used in Http Server header.
#defineME_MAX_CACHE_DURATION   (86400 * 1000)
 Default cache lifespan to 1 day.
#defineME_MAX_CACHE_ITEM   (256 * 1024)
 Maximum cachable item size.
#defineME_MAX_CHUNK   (8 * 1024)
 Maximum chunk size for transfer chunk encoding.
#defineME_MAX_CLIENTS   32
 Maximum unique client IP addresses.
#defineME_MAX_CLIENTS_HASH   131
 Hash table for client IP addresses.
#defineME_MAX_CONNECTIONS   50
 Maximum concurrent client endpoints.
#defineME_MAX_HEADERS   8192
 Maximum size of the headers (8K).
#defineME_MAX_HPACK_SIZE   4096
 Maximum size of the hpack table.
#defineME_MAX_INACTIVITY_DURATION   (30 * 1000)
 Default keep alive between requests timeout (30 sec).
#defineME_MAX_IOVEC   16
 Number of fragments in a single socket write.
#defineME_MAX_KEEP_ALIVE   400
 Maximum requests per network.
#defineME_MAX_NUM_HEADERS   64
 Maximum number of header lines.
#defineME_MAX_PARSE_DURATION   (5 * 1000)
 Default request parse header timeout (5 sec).
#defineME_MAX_PING_DURATION   (30 * 1000)
 WSS ping defeat Keep-Alive timeouts (30 sec).
#defineME_MAX_PROCESSES   10
 Maximum concurrent processes.
#defineME_MAX_REQUEST_DURATION   (5 * 60 * 1000)
 Default request timeout (5 minutes).
#defineME_MAX_REQUESTS_PER_CLIENT   20
 Maximum concurrent requests per client.
#defineME_MAX_REWRITE   20
 Maximum URI rewrites.
#defineME_MAX_ROUTE_MAP_HASH   17
 Size of the route mapping hash.
#defineME_MAX_ROUTE_MATCHES   32
 Maximum number of submatches in routes.
#defineME_MAX_RX_BODY   (512 * 1024)
 Maximum incoming body size (512K).
#defineME_MAX_RX_FORM   (512 * 1024)
 Maximum incoming form size (512K).
#defineME_MAX_SESSION_DURATION   (5 * 60 * 1000)
 Default session inactivity timeout (5 mins).
#defineME_MAX_SESSION_HASH   31
 Hash table for session data.
#defineME_MAX_SESSIONS   100
 Maximum concurrent sessions.
#defineME_MAX_STREAMS   20
 Default maximum concurrent streams per network.
#defineME_MAX_TX_BODY   HTTP_UNLIMITED
 Maximum buffer for response data.
#defineME_MAX_UPLOAD   HTTP_UNLIMITED
 Maximum file upload size.
#defineME_MAX_URI   512
 Reasonable URI size.
#defineME_MAX_WSS_FRAME   (4 * 1024)
 Default max WebSockets message frame size.
#defineME_MAX_WSS_MESSAGE   (2147483647)
 Default max WebSockets message size (2GB).
#defineME_MAX_WSS_PACKET   (8 * 1024)
 Default size to provide to application in one packet.
#defineME_MAX_WSS_SOCKETS   25
 Default max WebSockets.
#defineME_QUEUE_MAX_FACTOR   4
 Queue max set to packetSize * factor.
#defineME_XSRF_COOKIE   "XSRF-TOKEN"
 CSRF token cookie name.
#defineME_XSRF_HEADER   "X-XSRF-TOKEN"
 CSRF token name in Http headers.
#defineME_XSRF_PARAM   "-xsrf-"
 CSRF parameter in form fields.
#defineWS_MAX_CONTROL   125
 Maximum bytes in control message.
#defineWS_MSG_BINARY   0x2
 httpSendBlock type for binary messages.
#defineWS_MSG_CLOSE   0x8
 httpSendBlock type for close message.
#defineWS_MSG_CONT   0x0
 Continuation of WebSocket message.
#defineWS_MSG_CONTROL   0x8
 Start of control messages.
#defineWS_MSG_MAX   0xB
 Max message type for httpSendBlock.
#defineWS_MSG_PING   0x9
 httpSendBlock type for ping messages.
#defineWS_MSG_PONG   0xA
 httpSendBlock type for pong messages.
#defineWS_MSG_TEXT   0x1
 httpSendBlock type for text messages.
#defineWS_STATE_CLOSED   3
 WebSocket is closed.
#defineWS_STATE_CLOSING   2
 WebSocket is closing.
#defineWS_STATE_CONNECTING   0
 WebSocket connection is being established.
#defineWS_STATE_OPEN   1
 WebSocket handsake is complete and ready for communications.
#defineWS_STATUS_COMMS_ERROR   1006
 TCP/IP communications error.
#defineWS_STATUS_FRAME_TOO_LARGE   1004
 Reserved.
#defineWS_STATUS_GOING_AWAY   1001
 Endpoint is going away.
#defineWS_STATUS_INTERNAL_ERROR   1011
 Server terminating due to an internal error.
#defineWS_STATUS_INVALID_UTF8   1007
 Text message has invalid UTF-8.
#defineWS_STATUS_MAX   5000
 Maximum error status (less one).
#defineWS_STATUS_MESSAGE_TOO_LARGE   1009
 Message is too large.
#defineWS_STATUS_MISSING_EXTENSION   1010
 Unsupported WebSockets extension.
#defineWS_STATUS_NO_STATUS   1005
 No status was received from the peer in closing.
#defineWS_STATUS_OK   1000
 Normal closure.
#defineWS_STATUS_POLICY_VIOLATION   1008
 Application level policy violation.
#defineWS_STATUS_PROTOCOL_ERROR   1002
 WebSockets protocol error.
#defineWS_STATUS_TLS_ERROR   1015
 TLS handshake error.
#defineWS_STATUS_UNSUPPORTED_TYPE   1003
 Unsupported message data type.
#defineWS_VERSION   13
 Current WebSocket specification version.
#definehttpIsClient   (net && !net->endpoint)
 Test if the network is a client-side network.
#definehttpIsServer   (net && net->endpoint)
 Test if the network is a server-side network.

Http

Http

Http service object.

Description:
Configuration is not thread safe and must occur at initialization time when the application is single threaded. If the configuration is modified when the application is multithreaded, all requests must be first be quiesced.
See Also:
HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
API Stability:
Internal.
Fields:
struct HttpStage *actionHandler Action handler.
intactiveProcesses Count of active external processes.
MprHash *addresses Monitored per-IP-address counters.
MprHash *authStores Available password stores.
MprHash *authTypes Available authentication protocol types.
MprTimebooted Time the server started.
struct HttpStage *cacheFilter Cache filter.
struct HttpStage *cacheHandler Cache filter.
struct HttpStage *cgiConnector CGI connector.
struct HttpStage *cgiHandler CGI handler.
struct HttpStage *chunkFilter Chunked transfer encoding filter.
struct HttpStage *clientHandler Client-side handler (dummy).
struct HttpLimits *clientLimits Client resource limits.
struct HttpRoute *clientRoute Default route for clients.
void *context Embedding context.
MprList *counters List of counters.
char *currentDate Date string for HTTP response headers.
MprTickscurrentTime When currentDate was last calculated (ticks).
MprHash *dateCache Cache of date modified times.
char *defaultClientHost Default ip address.
intdefaultClientPort Default port.
MprHash *defenses List of Defenses.
struct HttpStage *dirHandler Directory listing handler.
struct HttpStage *egiHandler Embedded Gateway Interface (EGI) handler.
struct HttpStage *ejsHandler Ejscript Web Framework handler.
MprList *endpoints Currently configured listening endpoints.
HttpEnvCallbackenvCallback SetEnv callback.
struct HttpStage *espHandler ESP Web Framework handler.
struct HttpStage *fileHandler Static file handler.
intflags Open flags.
MprForkCallbackforkCallback Callback in child after fork().
intgid Group Id.
cchar *group O/S application group name.
intgroupChanged Group name changed.
MprList *hosts List of host objects.
struct HttpStage *http1Filter Http/1 filter.
struct HttpStage *http2Filter Http/2 filter.
struct HttpStage *httpFilter Http filter.
HttpListenCallbacklistenCallback Invoked when creating listeners.
cchar *localPlatform Local (dev) platform os-arch-profile (lower case).
MprTicksmonitorPeriod Minimum monitor period.
MprList *monitors List of monitors.
intmonitorsStarted Monitors are running.
MprMutex *mutex Multithread sync.
struct HttpStage *netConnector Default network connector.
MprList *networks Currently open network connections.
intnextAuth Auth object version vector.
MprTicksnow Current time in ticks.
MprHash *parsers Table config parser callbacks.
struct HttpStage *passHandler Pass through handler.
struct HttpStage *phpHandler PHP through handler.
cchar *platform Target platform os-arch-profile (lower case).
cchar *platformDir Path to platform directory containing binaries.
char *proxyHost Proxy ip address.
intproxyPort Proxy port.
struct HttpStage *rangeFilter Ranged requests filter.
MprHash *remedies List of Defense Remedies.
HttpRequestCallbackrequestCallback Request completion callback.
MprHash *routeConditions Http route condition functions.
MprHash *routeSets Http route sets functions.
MprHash *routeTargets Http route target functions.
MprHash *routeUpdates Http route update functions.
char *secret Random bytes for authentication.
struct HttpLimits *serverLimits Server resource limits.
MprCache *sessionCache Session state cache.
char *software Software name and version.
MprHash *stages Possible stages in connection pipelines.
intstartLevel Start endpoint trace level.
MprList *staticHeaders HTTP/2 static headers.
intstaticLink Target platform is using a static linking.
MprHash *statusCodes Http status codes.
struct HttpStage *tailFilter Tail filter.
MprEvent *timer Admin service timer.
MprEvent *timestamp Timestamp timer.
uint64totalConnections Total connections accepted.
uint64totalRequests Total requests served.
HttpTrace *trace Default tracing configuration.
inttraceLevel Current request trace level.
intuid User Id.
struct HttpStage *uploadFilter Upload filter.
cchar *user O/S application user name.
intuserChanged User name changed.
struct HttpStage *webSocketFilter WebSocket filter.
void httpAddOption (MprHash *options, cchar *field, cchar *value)

Add an option to the options table.

Parameters:
optionsOption table returned from httpGetOptions.
fieldField key name.
valueValue to use for the field.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpApplyChangedGroup (void )

Apply the changed group ID.

Description:
Apply configuration changes and actually change the group id.
Returns:
Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpApplyChangedUser (void )

Apply the changed user ID.

Description:
Apply configuration changes and actually change the user id.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpApplyUserGroup (void )

Apply the changed user and group ID.

Description:
Apply configuration changes and actually change the user and group id.
Returns:
Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
bool httpConfigure (HttpConfigureProc proc, void *arg, MprTicks timeout)

Alter the configuration by first quiescing all Http activity.

This waits until there are no open connections and then invokes the configuration callback while blocking further connections. When the callback completes, connections are resumed with the new configuration. This callback is required because configuration of the Http engine must be done when single-threaded
Parameters:
procFunction of the type HttpConfigureProc.
argReference argument to pass to the callback proc. Can be a managed or an unmanaged reference.
timeoutTimeout in milliseconds to wait. Set to -1 to use the default server inactivity timeout. Set to zero to wait forever.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
Http * httpCreate (int flags)

Create a Http service object.

Description:
Create a http service object. One http service object should be created per application.
Parameters:
flagsSet to zero to initialize bo Initialize the client-side support only.
Returns:
The http service object.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpDestroy (void )

Destroy the Http service.

Description:
This routine is invoked as the final stage in shutting down the http service. It stops the request timeout timer and releases all http memory.
API Stability:
Internal.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void * httpGetContext (void )

Get the http context object.

Returns:
The http context object defined via httpSetContext.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
char * httpGetDateString (MprPath *sbuf)

Get the time as an ISO date string.

Parameters:
sbufOptional path buffer. If supplied, the modified time of the path is used. If NULL, then the current time is used.
Returns:
RFC822 formatted date string.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void * httpGetOption (MprHash *options, cchar *field, cchar *defaultValue)

Extract a field value from an option string.

Parameters:
optionsOption string of the form: "field='value' field='value'...".
fieldField key name.
defaultValueValue to use if "field" is not found in options.
Returns:
Option value.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
MprHash * httpGetOptionHash (MprHash *options, cchar *field)

Get an option value that is itself an object (hash).

Description:
This returns an option value that is an instance of MprHash. When deserializing a JSON option string which contains multiple levels, this routine can be used to extract lower option container values.
Parameters:
optionsOptions object to examine.
fieldProperty to return.
Returns:
An MprHash instance for the given field. This will contain option sub-properties.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
MprHash * httpGetOptions (cchar *options)

Convert an options string into an options table.

Parameters:
optionsOption string of the form: "{field:'value', field:'value'}" This is a sub-set of the JSON syntax. Arrays are not supported.
Returns:
Options table.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpGetUserGroup (void )
int httpInitParser (void )

Initialize the Http configuration parser.

Returns:
Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpInsertOption (MprHash *options, cchar *field, cchar *value)

Add an option to the options table.

Description:
If the field already exists, the added value is inserted prior to the existing value.
Parameters:
optionsOption table returned from httpGetOptions.
fieldField key name.
valueValue to use for the field.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
struct HttpEndpoint * HttpEndpoint* httpLookupEndpoint (cchar *ip, int port)

Lookup a listening endpoint.

Parameters:
ipListening IP address to look for.
portListening port number.
Returns:
HttpEndpoint object.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
struct HttpHost * HttpHost* httpLookupHost (cchar *name)

Lookup a host by name.

Parameters:
nameThe name of the host to find.
Returns:
The corresponding host object.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
cchar * httpLookupStatus (int status)

Lookup a Http status code.

Description:
Lookup the code and return the corresponding text message briefly expaining the status.
Parameters:
statusHttp status code.
Returns:
Text message corresponding to the status code.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
bool httpOption (MprHash *options, cchar *field, cchar *value, int useDefault)

Test a field value from an option string.

Parameters:
optionsOption string of the form: "field='value' field='value'...".
fieldField key name.
valueTest if the field is set to this value.
useDefaultIf true and "field" is not found in options, return true.
Returns:
Allocated value string.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpParsePlatform (cchar *platform, cchar **os, cchar **arch, cchar **profile)

Parse a platform string.

Parameters:
platformThe platform string. Must be of the form: os-arch-profile.
osParsed O/S portion.
archParsed architecture portion.
profileParsed profile portion.
Returns:
Zero if successful, otherwise a negative Mpr error code.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpRemoveOption (MprHash *options, cchar *field)

Remove an option.

Description:
Remove a property from an options hash.
Parameters:
optionsOptions table returned from httpGetOptions.
fieldProperty field to remove.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpSetContext (void *context)
void httpSetDefaultClientHost (cchar *host)

Define a default client host.

Description:
Define a default host to use for client connections if the URI does not specify a host.
Parameters:
hostHost or IP address.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpSetDefaultClientPort (int port)

Define a default client port.

Description:
Define a default port to use for client connections if the URI does not define a port.
Parameters:
portInteger port number.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpSetGroupAccount (cchar *group)

Set the group account.

Description:
Define the group account name under which to run the process.
Parameters:
groupGroup name. Must be defined in the system group database.
Returns:
Zero if successful, otherwise a negative Mpr error code.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpSetOption (MprHash *options, cchar *field, cchar *value)

Set an option.

Description:
Set a property in an options hash.
Parameters:
optionsOptions table returned from httpGetOptions.
fieldProperty field to set.
valueProperty value to use.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpSetPlatform (cchar *platform)

Set platform description.

Description:
Some web frameworks need to recompile sources before serving requests (ESP). These need access to the http libraries to link with.
Parameters:
platformPlatform string of the form: OS-ARCH-PROFILE.
Returns:
Zero if the platform string parses, otherwise a negative Mpr error code.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
int httpSetPlatformDir (cchar *platform)

Set platform directory location.

Description:
Set the platform directory location which contains libraries and headers for the application.
Parameters:
platformPath to the platform directory.
Returns:
Zero if successful, otherwise a negative Mpr error code.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware
void httpSetProxy (cchar *host, int port)

Define a Http proxy host to use for all client connect requests.

Description:
Define a http proxy host to communicate via when accessing the net.
Parameters:
hostProxy host name or IP address.
portProxy host port number.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetSoftware
void httpSetSoftware (cchar *description)

Set the software description.

Parameters:
descriptionString describing the Http software. By default, this is set to HTTP_NAME.
API Stability:
Stable.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
int httpSetUserAccount (cchar *user)

Set the user account.

Description:
Define the user account name under which to run the process.
Parameters:
userUser name. Must be defined in the system password database.
Returns:
Zero if successful, otherwise a negative Mpr error code.
API Stability:
Evolving.
See Also:
Http, HttpEndpoint, HttpStream, httpConfigure, httpCreate, httpGetContext, httpGetDateString, httpLookupEndpoint, httpLookupStatus, httpSetContext, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy, httpSetSoftware

HttpAuth

HttpAuth

Authorization.

Description:
HttpAuth is the foundation authorization object and is used by HttpRoute. It stores the authorization configuration information required to determine if a client request should be permitted access to a given resource.
See Also:
HttpAskLogin, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
API Stability:
Internal.
Fields:
MprHash *abilities Set of required abilities (all are required).
MprHash *allow Clients to allow.
char *cipher Encryption cipher.
MprHash *deny Clients to deny.
intflags Authorization flags.
char *loggedInPage Target URI after logging in.
char *loggedOutPage Target URI after logging out.
char *loginPage Web page for user login for 'form' type.
struct HttpAuth *parent Parent auth.
MprHash *permittedUsers Set of valid users.
char *qop Quality of service.
char *realm Realm of access.
MprHash *roles Hash of roles.
HttpAuthStore *store Authorization password backend (system|file|custom).
HttpAuthType *type Authorization protocol type (basic|digest|form|custom).
MprHash *userCache Cache of authenticated users.
char *username Automatic login username. Password not required if defined.
HttpVerifyUserverifyUser Password verification.
HttpRole * httpAddRole (HttpAuth *auth, cchar *role, cchar *abilities)

Add a role.

If the role already exists, the role is updated
Description:
This creates the role with given abilities. Ability words can also be other roles.
Parameters:
authAuth object allocated by httpCreateAuth
roleRole name to add.
abilitiesSpace separated list of abilities.
Returns:
Allocated role object.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
HttpUser * httpAddUser (HttpAuth *auth, cchar *user, cchar *password, cchar *abilities)

Add a user.

If the user already exists, the user is updated
Description:
This creates the user and adds the user to the authentication database.
Parameters:
authAuth object allocated by httpCreateAuth
userUser name to add.
passwordUser password. The password should not be encrypted. The backend will encrypt as required.
abilitiesSpace separated list of abilities.
Returns:
The User object allocated or NULL for an error.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
bool httpCanUser (HttpStream *stream, cchar *abilities)

Test if a user has the required abilities.

Parameters:
streamHttpStream stream object created via httpCreateStream object.
abilitiesComma separated list of abilities to test for. If null, then use the required abilities defined for the current request route.
Returns:
True if the user has all the required abilities.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpComputeAllUserAbilities (HttpAuth *auth)
void httpComputeUserAbilities (HttpAuth *auth, HttpUser *user)
HttpAuth * httpCreateAuth (void )
HttpAuthStore * httpCreateAuthStore (cchar *name, HttpVerifyUser verifyUser)

Add an authorization store for password validation.

The pre-supplied types are "config" and "system"
Description:
This creates an AuthType object with the defined name and callbacks.
Parameters:
nameUnique authorization type name.
verifyUserCallback to verify the username and password contained in the HttpStream object passed to the callback.
Returns:
Auth store if successful, otherwise zero.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
int httpCreateAuthType (cchar *name, HttpAskLogin askLogin, HttpParseAuth parse, HttpSetAuth setAuth)

Create an authorization protocol type.

The pre-supplied types are 'basic', 'digest' and 'form'
Description:
This creates an AuthType with the defined name and callbacks. The basic and digest types are supported by most browsers. The form type is implemented via web form requests over HTTP.
Parameters:
nameUnique authorization type name.
askLoginCallback to generate a client login response.
parseCallback to parse the HTTP authentication headers.
setAuthCallback to set the HTTP response authentication headers.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
bool httpIsAuthenticated (HttpStream *stream)
bool httpLogin (HttpStream *stream, cchar *username, cchar *password)

Log the user in.

Description:
This will verify the supplied username and password. If the user is successfully logged in, the user identity will be stored in session state for fast authentication on subsequent requests. Note: this does not verify any user abilities.
Parameters:
streamHttpStream stream object.
usernameUser name to authenticate.
passwordPassword for the user.
Returns:
True if the username and password have been authenticated.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpLogout (HttpStream *stream)
HttpRole * httpLookupRole (HttpAuth *auth, cchar *name)
HttpUser * httpLookupUser (HttpAuth *auth, cchar *name)

Lookup a user by username.

Description:
This looks up a user in the internal user store. This is only used i.
Parameters:
authHttpAuth object. Stored in HttpStream.rx.route.auth.
nameUsername.
Returns:
User object.
API Stability:
Evolving.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
int httpRemoveRole (HttpAuth *auth, cchar *role)
int httpRemoveUser (HttpAuth *auth, cchar *user)
void httpSetAuthAllow (HttpAuth *auth, cchar *ip)
void httpSetAuthAnyValidUser (HttpAuth *auth)
void httpSetAuthDeny (HttpAuth *auth, cchar *ip)
void httpSetAuthFormDetails (struct HttpRoute *route, cchar *loginPage, cchar *loginService, cchar *logoutService, cchar *loggedInPage, cchar *loggedOutPage)

Define login service URLs for use with "form" authentication.

Description:
This defines the login form URL and login/out service URLs. Set arguments to null if they are not required because the application is implementing its own redirection management during login. This API should not be used for web frameworks like ESP or PHP that define their own login/out services.
Parameters:
routeRoute from which to inherit when creating a route for the login pages and services.
loginPageWeb page URI for the user to enter username and password.
loginServiceURI to use for the internal login service. To use your own login URI, set to this the empty string.
logoutServiceURI to use to log the user out. To use your won logout URI, set this to the empty string.
loggedInPageThe client is redirected to this URI once logged in. Use a "referrer:" prefix to the URI to redirect the user to the referring URI before the loginPage. If the referrer cannot be determined, the base URI is utilized.
loggedOutPageThe client is redirected to this URI once logged in. Use a "referrer:" prefix to the URI to redirect the user to the referring URI before the loginPage. If the referrer cannot be determined, the base URI is utilized.
API Stability:
Evolving.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpSetAuthLogin (HttpAuth *auth, cchar *uri)

Define the login page for use with authentication.

Parameters:
authAuthorization object allocated by httpCreateAuth
uriURI for the login page. Can use "https:///page" to specify the SSL protocol with the current domain.
API Stability:
Evolving.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpSetAuthOrder (HttpAuth *auth, int order)
void httpSetAuthPermittedUsers (HttpAuth *auth, cchar *users)
void httpSetAuthQop (HttpAuth *auth, cchar *qop)

Set the required quality of service for digest authentication.

Description:
This configures the basic or digest authentication for the auth object.
Parameters:
authAuth object allocated by httpCreateAuth
qopQuality of service description.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpSetAuthRealm (HttpAuth *auth, cchar *realm)

Set the required realm for basic or digest authentication.

Description:
This configures the authentication realm. The realm is displayed to the user in the browser login dialog box.
Parameters:
authAuth object allocated by httpCreateAuth
realmAuthentication realm.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpSetAuthRequiredAbilities (HttpAuth *auth, cchar *abilities)
void httpSetAuthSession (HttpAuth *auth, bool noSession)

Control whether a session and session cookie will be created for user logins for this authentication route.

Description:
By default, a session and response cookie are created when a user is authenticated via httpLogin. This boosts performance because subsequent requests can supply the cookie and bypass authentication for each subseqent request. This API permits the default behavior to be suppressed and thus no cookie or session will be created.
Parameters:
authAuth object created via httpCreateAuth
noSessionSet to true to suppress creation of sessions or cookies.
API Stability:
Evolving.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
int httpSetAuthStore (HttpAuth *auth, cchar *store)
void httpSetAuthStoreSessions (HttpAuthStore *store, bool noSession)

Control whether sessions and session cookies are created for user logins.

Description:
By default, a session and response cookie are created when a user is authenticated via httpLogin. This boosts performance because subsequent requests can supply the cookie and bypass authentication for each subseqent request. This API permits the default behavior to be suppressed and thus no cookie or session will be created.
Parameters:
storeAuthStore object created via httpCreateAuthStore
noSessionSet to true to suppress creation of sessions or cookies.
API Stability:
Evolving.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType, httpSetAuthUsername
void httpSetAuthStoreVerify (HttpAuthStore *store, HttpVerifyUser verifyUser)

Set the global verify callback for an authentication store.

Description:
The verification callback is invoked to verify user credentials when authentication is required. The callback has the signature: typedef bool (*HttpVerifyUser)(HttpStream *stream, cchar *username, cchar *password);.
Parameters:
storeAuthStore object allocated by httpCreateAuthStore
verifyUserVerification callback.
API Stability:
Evolving.
See Also:
httpSetAuthVerify
int httpSetAuthType (HttpAuth *auth, cchar *proto, cchar *details)

Set the authentication protocol type to use.

Parameters:
authAuth object allocated by httpCreateAuth
protoProtocol name to use. Select from: 'basic', 'digest', 'form' or 'none'. Set to NULL or 'none' to disable authentication.
detailsExtra protocol details.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthUsername
void httpSetAuthUsername (HttpAuth *auth, cchar *username)

Set an automatic login username.

Description:
If defined, no password is required and the user will be automatically logged in as this username.
Parameters:
authAuth object allocated by httpCreateAuth
usernameUsername to automatically login with.
API Stability:
Stable.
See Also:
HttpAskLogin, HttpAuth, HttpAuthType, HttpRole, HttpSetAuth, HttpUser, HttpVerifyUser, HttpVerifyUser, httpAddRole, httpAddUser, httpCanUser, httpComputeAllUserAbilities, httpComputeUserAbilities, httpCreateAuth, httpIsAuthenticated, httpLogin, httpRemoveRole, httpRemoveUser, httpSetAuthAllow, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthLogin, httpSetAuthOrder, httpSetAuthPermittedUsers, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredAbilities, httpSetAuthType
void httpSetAuthVerify (HttpAuth *auth, HttpVerifyUser verifyUser)

Set the verify callback for an authentication object that is part of a route.

Parameters:
authAuth object allocated by httpCreateAuth
verifyUserVerification callback.
API Stability:
Evolving.
See Also:
httpSetAuthStoreVerify

HttpCache

HttpCache

Cache Control.

Description:
Configuration is not thread safe and must occur at initialization time when the application is single threaded. If the configuration is modified when the application is multithreaded, all requests must be first be quiesced.
See Also:
httpAddCache, httpUpdateCache
API Stability:
Internal.
Fields:
MprTicksclientLifespan Lifespan for client cached content.
MprHash *extensions Extensions to cache.
intflags Cache control flags.
MprHash *methods Methods to cache.
MprTicksserverLifespan Lifespan for server cached content.
MprHash *types MimeTypes to cache.
MprHash *uris URIs to cache.
void httpAddCache (struct HttpRoute *route, cchar *methods, cchar *uris, cchar *extensions, cchar *types, MprTicks clientLifespan, MprTicks serverLifespan, int flags)

Add caching for response content.

Description:
This call configures caching for request responses. Caching may be used for any HTTP method, though typically it is most useful for state-less GET requests. Output data may be uniquely cached for requests with different request parameters (query, post, and route parameters).

When server-side caching is requested and manual-mode is not enabled, the request response will be automatically cached. Subsequent client requests will revalidate the cached content with the server. If the server-side cached content has not expired, a HTTP Not-Modified (304) response will be sent and the client will use its client-side cached content. This results in a very fast transaction with the client as no response data is sent. Server-side caching will cache both the response headers and content.

If manual server-side caching is requested, the response will be automatically cached, but subsequent requests will require the handler to explicitly send cached content by calling httpWriteCached.

If client-side caching is requested, a 'Cache-Control' Http header will be sent to the client with the caching 'max-age' set to the lifespan argument value (converted to seconds). This causes the client to serve client-cached content and to not contact the server at all until the max-age expires. Alternatively, you can use httpSetHeader to explicitly set a 'Cache-Control' header. For your reference, here are some keywords that can be used in the Cache-Control Http header.

'max-age' Maximum time in seconds the resource is considered fresh. 's-maxage' Maximum time in seconds the resource is considered fresh from a shared cache. 'public' marks authenticated responses as cacheable. 'private' shared caches may not store the response. 'no-cache' cache must re-submit request for validation before using cached copy. 'no-store' response may not be stored in a cache. 'must-revalidate' forces clients to revalidate the request with the server. 'proxy-revalidate' similar to must-revalidate except only for proxy caches.

Use client-side caching for static content that will rarely change or for content for which using 'reload' in the browser is an adequate solution to force a refresh. Use manual server-side caching for situations where you need to explicitly control when and how cached data is returned to the client. For most other situations, use server-side caching.
Parameters:
routeHttpRoute object.
methodsList of methods for which caching should be enabled. Set to a comma or space separated list of method names. Method names can be any case. Set to null or '*' for all methods. Example: 'GET, POST'.
urisSet of URIs to cache. If the URI is set to '*' all URIs for that action are uniquely cached. If the request has POST data, the URI may include such post data in a sorted query format. E.g. {uri: /buy?item=scarf&quantity=1}.
extensionsList of document extensions for which caching should be enabled. Set to a comma or space separated list of extensions. Extensions should not have a period prefix. Set to null, '' or '*' for all extensions. Example: 'html, css, js'. The URI may include request parameters in sorted www-urlencoded format. For example: /example.esp?hobby=sailing&name=john.
typesList of document mime types for which caching should be enabled. Set to a comma or space separated list of types. The mime types are those that correspond to the document extension and NOT the content type defined by the handler serving the document. Set to null or '*' for all types. Example: image/gif, application/x-php.
clientLifespanLifespan of client cache items in milliseconds. If not set to positive integer, the lifespan will default to the route lifespan.
serverLifespanLifespan of server cache items in milliseconds. If not set to positive integer, the lifespan will default to the route lifespan.
flagsCache control flags. Select HTTP_CACHE_MANUAL to enable manual mode. In manual mode, cached content will not be automatically sent. Use httpWriteCached in the request handler to write previously cached content.

Select HTTP_CACHE_CLIENT to enable client-side caching. In this mode a 'Cache-Control' Http header will be sent to the client with the caching 'max-age'. WARNING: the client will not send any request for this URI until the max-age timeout has expired.

Select HTTP_CACHE_RESET to first reset existing caching configuration for this route.

Select HTTP_CACHE_SERVER to define the server-side caching mode.

Select HTTP_CACHE_UNIQUE to uniquely cache requests with different request parameters.
Returns:
A count of the bytes actually written.
API Stability:
Evolving.
See Also:
HttpCache, httpUpdateCache
ssize httpUpdateCache (HttpStream *stream, cchar *uri, cchar *data, MprTicks lifespan)

Update the cached content for a URI.

Parameters:
streamHttpStream stream object.
uriThe request URI for which to update the cache. The URI may contain the request parameters in sorted www-urlencoded format. The URI should include any route prefix.
dataData to cache for the URI. If you wish to cache response headers, include those at the start of the data followed by an additional new line.
lifespanLifespan in milliseconds for the cached content.
API Stability:
Evolving.
See Also:
HttpCache, httpAddCache
ssize httpWriteCached (HttpStream *stream)

Write the cached content for a URI to the client.

Description:
This call explicitly writes cached content to the client. It is useful when the caching is configured in manual mode via the HTTP_CACHE_MANUAL flag to httpAddCache
Parameters:
streamHttpStream stream object.
API Stability:
Evolving.
See Also:
HttpCache, httpAddCache, httpUpdateCache

HttpDir

HttpDir

Directory object for the DirHandler.

API Stability:
Internal.
Fields:
HttpDir * httpGetDirObj (HttpRoute *route)

Get the HttpDir object for a route.

API Stability:
Evolving.
See Also:

HttpEndpoint

HttpEndpoint

Listening endpoints.

See Also:
httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
API Stability:
Internal.
Fields:
intasync Listening is in async mode (non-blocking).
void *context Embedding context.
MprDispatcher *dispatcher Event dispatcher.
intflags Endpoint control flags.
MprList *hosts List of host objects.
Http *http Http service object.
char *ip Listen IP address. May be null if listening on all interfaces.
HttpLimits *limits Alias for first host, default route resource limits.
MprMutex *mutex Multithread sync.
HttpNotifiernotifier Default connection notifier callback.
intport Listen port.
MprSocket *sock Listening socket.
MprSsl *ssl SSL configurations to use.
HttpNet * httpAccept (HttpEndpoint *endpoint, MprEvent *event)

Accept a new connection.

Accept a new client connection on a new socket. If multithreaded, this will come in on a worker thread dedicated to this connection. This is called from the listen wait handler
Parameters:
endpointThe endpoint on which the server was listening.
eventMpr event object.
Returns:
A HttpNet object representing the new network.
API Stability:
Internal.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
void httpAddHostToEndpoint (HttpEndpoint *endpoint, struct HttpHost *host)

Add a host to an endpoint.

Description:
Add the host to the endpoint's list of hosts. A listening endpoint may have multiple virutal hosts.
Parameters:
endpointEndpoint to which the host will be added.
hostHttpHost object to add.
Returns:
"Zero" if the host can be added.
API Stability:
Internal.
See Also:
HttpEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
HttpEndpoint * httpCreateConfiguredEndpoint (struct HttpHost *host, cchar *home, cchar *documents, cchar *ip, int port)

Create and configure a new endpoint.

Description:
Convenience function to create and configure a new endpoint without using a config file. If no host is supplied, a default host and route are created.
Parameters:
hostOptional HttpHost object.
homeHome directory for configuration files for the endpoint.
documentsDirectory containing the.
ipIP address to use for the endpoint. Set to null to listen on all interfaces.
portListening port number to use for the endpoint.
Returns:
A configured HttpEndpoint object instance.
API Stability:
Internal.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
HttpEndpoint * httpCreateEndpoint (cchar *ip, int port, MprDispatcher *dispatcher)

Create an endpoint object.

Description:
Creates a listening endpoint on the given IP:PORT. Use httpStartEndpoint to begin listening for client connections.
Parameters:
ipIP address on which to listen.
portIP port number.
dispatcherDispatcher to use. Can be null.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
void httpDestroyEndpoint (HttpEndpoint *endpoint)

Destroy the endpoint.

Description:
This destroys the endpoint created by httpCreateEndpoint. Calling this routine should not normally be necessary as the garbage collector will invoke as required.
Parameters:
endpointHttpEndpoint object returned from httpCreateEndpoint
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
void * httpGetEndpointContext (HttpEndpoint *endpoint)

Get the endpoint context object.

Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
Returns:
The endpoint context object defined via httpSetEndpointContext.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
int httpIsEndpointAsync (HttpEndpoint *endpoint)
struct HttpHost * HttpHost* httpLookupHostOnEndpoint (HttpEndpoint *endpoint, cchar *name)

Lookup a host name.

Description:
Lookup a host by name in the set of defined hosts for this endpoint.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
nameHost name to search for.
Returns:
An HttpHost object instance or null if the host cannot be found.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
int httpSecureEndpoint (HttpEndpoint *endpoint, struct MprSsl *ssl)

Secure an endpoint.

Description:
Define the SSL parameters for an endpoint. This must be done before starting listening on the endpoint via httpStartEndpoint
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
sslMprSsl object.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
int httpSecureEndpointByName (cchar *name, struct MprSsl *ssl)

Secure an endpoint by name.

Description:
Define the SSL parameters for an endpoint that is selected by name. This must be done before starting listening on the endpoint via httpStartEndpoint
Parameters:
nameEndpoint name. The endpoint name is comprised of the IP and port. For example: "127.0.0.1:7777".
sslMprSsl object.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
int httpSetEndpointAddress (HttpEndpoint *endpoint, cchar *ip, int port)

Set the endpoint IP address.

Description:
This call defines the endpoint's IP address and port number. If the endpoint has already been started, this will stop and restart the endpoint. Current requests will not be disturbed. This is useful to modify the endpoints address when using dynamically assigned IP addresses.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
ipIP address to use for the endpoint. Set to null to listen on all interfaces.
portListening port number to use for the endpoint.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
void httpSetEndpointAsync (HttpEndpoint *endpoint, int enable)
void httpSetEndpointContext (HttpEndpoint *endpoint, void *context)
void httpSetEndpointNotifier (HttpEndpoint *endpoint, HttpNotifier fn)

Define a notifier callback for this endpoint.

Description:
The notifier callback will be invoked as Http requests are processed.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
fnNotifier function.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpStartEndpoint, httpStopEndpoint
int httpStartEndpoint (HttpEndpoint *endpoint)

Start listening for client connections on an endpoint.

Description:
Opens the endpoint socket and starts listening for connections.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStopEndpoint
int httpStartEndpoints (void )

Start listening for client connections on all endpoints.

Description:
Opens all endpoints and starts listening for connections.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint
void httpStopEndpoint (HttpEndpoint *endpoint)

Stop the server listening for client connections.

Description:
Closes the socket endpoint. This preserves connections accepted via the listening endpoint.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
API Stability:
Stable.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint
void httpStopEndpoints (void )

Stop listening for client connections on all endpoints.

Description:
Closes all endpoints and stops listening for connections. Does not impact running requests.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateConfiguredEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpGetEndpointContext, httpIsEndpointAsync, httpLookupHostOnEndpoint, httpSecureEndpoint, httpSecureEndpointByName, httpSetEndpointAddress, httpSetEndpointAsync, httpSetEndpointContext, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint

HttpHost

HttpHost

Host Object.

Description:
A Host object represents a logical host. Several logical hosts may share a single HttpEndpoint.
See Also:
httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
API Stability:
Internal.
Fields:
HttpUri *canonical Canonical host name (optional canonial public name for redirections).
HttpEndpoint *defaultEndpoint Default endpoint for host.
HttpRoute *defaultRoute Default route for the host.
intflags Host flags.
cchar *hostname Host name portion only.
cchar *name Full host name with port.
void *nameCompiled Compiled name regular expression (not alloced).
struct HttpHost *parent Parent host to inherit aliases, dirs, routes.
MprCache *responseCache Response content caching store.
MprList *routes List of Route defintions.
HttpEndpoint *secureEndpoint Secure endpoint for host.
MprHash *streams Hash of mime-types to stream record.
int httpAddRoute (HttpHost *host, HttpRoute *route)

Add a route to a host.

Description:
Add the route to the host list of routes. During request route matching, routes are processed in order, so it is important to define routes in the order in which you wish to match them.
Parameters:
hostHttpHost object.
routeRoute to add.
Returns:
"Zero" if the route can be added.
API Stability:
Stable.
See Also:
HttpHost, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
HttpHost * httpCloneHost (HttpHost *parent)

Clone a host.

Description:
The parent host is cloned and a new host returned. The new host inherites the parent's configuration.
Parameters:
parentParent HttpHost object to clone.
Returns:
The new HttpHost object.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
HttpHost * httpCreateDefaultHost (void )

Create the default host.

Description:
Create and define a default host. The host is added to the Http service's list of hosts. A default route is created for the host.
Returns:
The new HttpHost object.
API Stability:
Evolving.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
HttpHost * httpCreateHost (void )

Create a host.

Description:
Create a new host object. The host is added to the Http service's list of hosts.
Returns:
The new HttpHost object.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
HttpHost * httpGetDefaultHost (void )

Get the default host defined via httpSetDefaultHost.

Returns:
The defaul thost object.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
bool httpGetStreaming (struct HttpHost *host, cchar *mime, cchar *uri)

Determine if input body content should be streamed or buffered for requests with content of a given mime type.

Description:
The mime type and URI are used to match the request.
Parameters:
hostHost to modify.
mimeMime type to configure.
uriURI prefix to match with.
Returns:
True if input should be streamed. False if it should be buffered.
API Stability:
Evolving.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
void httpResetRoutes (HttpHost *host)

Reset the list of routes for the host.

Parameters:
hostHttpHost object.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpSetHostName, httpSetHostProtocol
void httpSetDefaultHost (HttpHost *host)

Set the default host for all servers.

Parameters:
hostHost to define as the default host.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
int httpSetHostCanonicalName (HttpHost *host, cchar *name)

Set the host canonical name.

Description:
The host canonical name is the public perferred name to use for the server. This is used when redirecting client requests for directories.
Parameters:
hostHttpHost object.
nameHost canonical name to use.
Returns:
Zero if successful. May return a negative MPR error code if the name is a regular expression and cannot be compiled.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
void httpSetHostDefaultEndpoint (HttpHost *host, HttpEndpoint *endpoint)

Set the default endpoint for a host.

Description:
The host may have a default endpoint that is used when doing redirections to http.
Parameters:
hostHost to examine.
endpointSecure endpoint to use as the default.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
void httpSetHostDefaultRoute (HttpHost *host, HttpRoute *route)

Set the default route for a host.

Description:
The host has a default route which holds default configuration. Typically the default route is not directly used when routing URIs. Rather other routes inherit from the default route and are used to respond to client requests.
Parameters:
hostHost to examine.
routeRoute to define as the default.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
int httpSetHostName (HttpHost *host, cchar *name)

Set the host name.

Description:
The host name is used when matching client requests to virtual hosts using the Http request Host header. If the host name starts with "*", it will match names that contain the name. If the host name ends with "*", it will match names that start with the name. If the host name begins and ends with a "/", the name is assumed to be a regular expression. Regular expressions may match multiple host names by using the "|" character to separate names.
Parameters:
hostHttpHost object.
nameHost name to use.
Returns:
Zero if successful. May return a negative MPR error code if the name is a regular expression and cannot be compiled.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostProtocol
void httpSetHostProtocol (HttpHost *host, cchar *protocol)

Set the host HTTP protocol version.

Description:
Set the host protocol version to either HTTP/1.0 or HTTP/1.1.
Parameters:
hostHttpHost object.
protocolSet to either HTTP/1.0 or HTTP/1.1.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName
void httpSetHostRoot (HttpHost *host, cchar *root)

Set the server root for a host.

Description:
The server root is used as the default directory to locate configuration files for the host.
Parameters:
hostHttpHost object.
rootDirectory path for the host server root.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
void httpSetHostSecureEndpoint (HttpHost *host, HttpEndpoint *endpoint)

Set the default secure endpoint for a host.

Description:
The host may have a default secure endpoint that is used when doing redirections to https.
Parameters:
hostHost to examine.
endpointSecure endpoint to use as the default.
API Stability:
Stable.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol
void httpSetStreaming (struct HttpHost *host, cchar *mime, cchar *uri, bool streaming)

Control if input body content should be streamed or buffered for requests with content of a given mime type.

Parameters:
hostHost to modify.
mimeMime type to configure.
uriURI prefix to match.
streamingSet to true to enable streaming for this mime type.
API Stability:
Evolving.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostName, httpSetHostProtocol

HttpLimits

HttpLimits

Http limits.

See Also:
httpCreateLimits, httpEaseLimits, httpInitLimits
API Stability:
Internal.
Fields:
intcacheItemSize Maximum size of a cachable item.
ssizechunkSize Maximum chunk size for transfer encoding.
intclientMax Maximum number of unique clients IP addresses.
intconnectionsMax Maximum number of simultaneous client connections.
intframeSize HTTP/2 maximum frame size.
intheaderMax Maximum number of header lines.
intheaderSize Maximum size of the total header.
inthpackMax HTTP/2 maximum size of the hpack header table.
MprTicksinactivityTimeout Timeout for keep-alive and idle requests (msec).
intkeepAliveMax Maximum number of Keep-Alive requests to perform per socket.
intpacketSize Maximum packet size for queues and stages.
intprocessMax Maximum number of processes (CGI).
intrequestMax Maximum number of simultaneous concurrent requests.
MprTicksrequestParseTimeout Time a request can take to parse the request headers (msec).
intrequestsPerClientMax Maximum number of requests per client IP.
MprTicksrequestTimeout Time a request can take (msec).
MprOffrxBodySize Maximum size of receive body data.
MprOffrxFormSize Maximum size of form data.
intsessionMax Maximum number of sessions.
MprTickssessionTimeout Time a session can persist (msec).
intstreamsMax HTTP/2 maximum number of streams per connection (both peer and self initiated).
MprOfftxBodySize Maximum size of transmission body content.
inttxStreamsMax HTTP/2 maximum number of streams the peer will permit per connection.
MprOffuploadSize Maximum size of an uploaded file.
inturiSize Maximum size of a uri.
intwebSocketsFrameSize Maximum size of sent WebSocket frames. Incoming frames have no limit except message size.
intwebSocketsMax Maximum number of WebSockets.
intwebSocketsMessageSize Maximum total size of a WebSocket message including all frames.
intwebSocketsPacketSize Maximum size of a WebSocket packet exchanged with the user callback.
MprTickswebSocketsPing Time between pings.
intwindow HTTP/2 Initial rx window size (size willing to receive).
HttpLimits * httpCreateLimits (int serverSide)

Create a new limits object.

Description:
Create and initialize a new limits object with default values.
Parameters:
serverSideSet to "true" for server side limits. Set to "false" for client side default limits.
Returns:
The allocated limits object.
API Stability:
Stable.
See Also:
HttpLimits, httpEaseLimits, httpInitLimits
void httpEaseLimits (HttpLimits *limits)

Ease the limits.

Description:
This increases the receive body size, transmission body size and upload size to the maximum sizes supported by the system. Client side limits are eased by default.
Parameters:
limitsLimits object. This can be either HttpHost.limits HttpStream.limits or HttpEndpoint.limits.
API Stability:
Stable.
See Also:
HttpLimits, httpCreateLimits, httpInitLimits
void httpInitLimits (HttpLimits *limits, bool serverSide)

Initialize a limits object with default values.

Parameters:
limitsLimits object to modify.
serverSideSet to "true" for server side limits. Set to "false" for client side default limits.
API Stability:
Stable.
See Also:
HttpLimits, httpCreateLimits, httpEaseLimits

HttpMonitor

HttpMonitor

Monitor control structure.

API Stability:
Internal.
Fields:
intcounterIndex Counter item index to monitor.
cchar *counterName Name of counter to monitor.
MprList *defenses List of defensive measures.
intexpr Expression. Set to '<' or '>'.
uint64limit Comparison limit value.
MprTicksperiod Frequence of comparison.
MprEvent *timer Monitor timer.
int httpAddCounter (cchar *name)

Add a counter to be monitored.

Parameters:
nameName of the counter.
Returns:
The counter index in HttpAddress.counters[] to use.
API Stability:
Evolving.
See Also:
int httpAddDefense (cchar *name, cchar *remedy, cchar *args)

Add a defense.

Parameters:
nameName of defensive policy.
remedyRemedy action to invoke. Standard remedies include: ban, cmd, delay, email, http and log. This can be null and the remedy can be specified via REMEDY=remedy in the args.
argsArguments to pass to the remedy. These may include ${tokens}.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
int httpAddDefenseFromJson (cchar *name, cchar *remedy, MprJson *jargs)

Add a defense using JSON arguments.

Parameters:
nameName of defensive policy.
remedyRemedy action to invoke. Standard remedies include: ban, cmd, delay, email, http and log. This can be null and the remedy can be specified via REMEDY=remedy in the args.
jargsArguments to pass to the remedy as a JSON object. These may include ${tokens}.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
int httpAddMonitor (cchar *counter, cchar *expr, uint64 limit, MprTicks period, cchar *defenses)

Add a monitor.

Parameters:
counterName of counter to monitor. Some of the standard counter names are: ActiveClients, ActiveConnections, ActiveRequests, ActiveProcesses, BadRequestErrors, LimitErrors, Memory, NotFoundErrors, NetworkIO, Requests, SSLErrors, TotalErrors.
exprExpression operator. Select from "<" or ">".
limitLimit value to compare with the counter value.
periodTime period over which to determine the counter value.
defensesList of defenses to invoke if the counter exceeds the limit value over the designated period.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
int httpAddRemedy (cchar *name, HttpRemedyProc remedy)

Add a remedy.

Parameters:
nameName of the remedy.
remedyRemedy callback function.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
int httpBanClient (cchar *ip, MprTicks period, int status, cchar *msg)

Ban a client IP from service.

Parameters:
ipClient IP address to ban.
periodPeriod in milliseconds to ban the client.
statusIf non-zero, then return a HTTP response to the client with this HTTP status.
msgIf non-null, then return a HTTP response with this message. If both status and msg are zero and null respectively, then do not send a response to the client, rather immediately close the network connection.
API Stability:
Evolving.
See Also:
void httpDumpCounters (void )

Print the monitor counters to the error log.

API Stability:
Evolving.
See Also:
int64 httpMonitorEvent (struct HttpStream *stream, int counter, int64 adj)

Monitor an event and validate against defined limits and monitored resources.

Description:
The Http library supports a suite of resource limits that restrict the impact of a request on the system. This call validates a processing event for the current request against the server's endpoint limits.
Parameters:
streamHttpStream stream object.
counterThe counter to adjust.
adjValue to adjust the counter by. May be positive or negative.
Returns:
Monitor value after applying the adjustment.
API Stability:
Evolving.
See Also:
int64 httpMonitorNetEvent (struct HttpNet *net, int counter, int64 adj)

Monitor a network event and validate against defined limits and monitored resources.

Description:
The Http library supports a suite of resource limits that restrict the impact of a request on the system. This call validates a processing event for the current request against the server's endpoint limits.
Parameters:
netNetwork object.
counterThe counter to adjust.
adjValue to adjust the counter by. May be positive or negative.
Returns:
Monitor value after applying the adjustment.
API Stability:
Evolving.
See Also:

HttpNet

HttpNet

Control object for the network connection.

See Also:
httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
API Stability:
Internal.
Fields:
HttpAddress *address Per-client IP address reference.
boolasync Connection is in async mode (non-blocking).
boolborrowed Socket has been borrowed.
MprOffbytesWritten Total bytes written.
MprList *connections List of connection streams.
void *context Embedding context (EjsRequest).
void *data Custom data.
intdelay Delay servicing requests due to defense strategy.
booldestroyed Net object has been destroyed.
MprDispatcher *dispatcher Event dispatcher.
void *ejs Embedding VM.
struct HttpEndpoint *endpoint Endpoint object (if set - indicates server-side).
booleof Socket has been closed.
boolerror Hard network error - cannot continue.
cchar *errorMsg Error message for the last request (if any).
uinteventMask Last IO event mask.
HttpFrame *frame Current frame being parsed.
boolgoaway Closing network connection (sent or received a goAway frame).
HttpQueue *holdq GC hold queue while scheduling.
Http *http Http service object.
boolinit Settings frame has been sent and network is ready to use.
HttpQueue *inputq Queue of packets received from the network (http-rx).
HttpIOCallbackioCallback I/O event callback.
char *ip Remote client IP address.
MprTickslastActivity Last activity on the connection.
intlastStreamID Last stream ID.
HttpLimits *limits Service limits.
MprDispatcher *newDispatcher New dispatcher if using a worker thread.
intnextStreamID Next stream ID.
HttpNotifiernotifier Http state change notification callback.
MprDispatcher *oldDispatcher Original dispatcher if using a worker thread.
HttpQueue *outputq Queue of packets to write to the network (http-tx).
boolownDispatcher Using own the dispatcher and should destroy when closing connection.
intownStreams Number of peer created streams.
void *pool Pool of VMs.
intport Remote port.
uintprotocol HTTP protocol: 0 for HTTP/1.0, 1 for HTTP/1.1 or 2+.
boolpush Receiver will accept push.
boolreceivedGoaway Received goaway frame.
HttpHeaderTable *rxHeaders Cache of HPACK rx headers.
boolsecure Using https.
intseqno Unique network sequence number.
HttpQueue *serviceq List of queues that require service.
intsession Currently parsing frame for this session.
boolskipTrace Omit trace from now on.
MprSocket *sock Underlying socket handle.
HttpQueue *socketq Queue of packets to write to the output socket (last queue).
inttimeout Connection timeout indication.
MprEvent *timeoutEvent Connection or request timeout event.
inttotalRequests Total number of requests serviced.
HttpTrace *trace Tracing configuration.
HttpHeaderTable *txHeaders Cache of HPACK tx headers.
boolworker Use worker.
MprEvent *workerEvent Event for running connection via a worker thread (used by ejs).
boolwriteBlocked Transmission writing is blocked.
void httpBorrowNet (HttpNet *net)

Borrow a network connection.

Description:
Borrow the network from Http. This effectively gains an exclusive loan of the network so that it cannot be destroyed while the loan is active. After the loan is complete, you must call return the network by calling httpReturnNet. Otherwise the network will not be freed and memory will leak.

The httpBorrowNet routine is used to stabilize a network while interacting with some outside service. Without this routine, the network could be destroyed while waiting. Many things can happen while waiting. For example: the client could disconnect or the network connection could timeout. These events will still be serviced while the network is borrowed, but the network object will not be destroyed.

While borrowed, you must not access the network object using foreign / non-MPR threads. If you need to do this, use mprCreateEvent to schedule an event to run on the networks's event dispatcher. This is essential to serialize access to the network object.

Before returning from the event callback, you must call httpReturnNet to end the exclusive loan. This restores normal processing of the connection and enables any required I/O events.

Parameters:
netHttpNet object created via httpCreateNet
API Stability:
Prototype.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
int httpConnectNet (HttpNet *net, cchar *ip, int port, MprSsl *ssl)

Connect the network to a remote peer.

Parameters:
netHttpNet Network object created via httpCreateNet
ipRemote IP address to connect to.
portTCP/IP port to connect to.
sslMprSsl object that defines the SSL context.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Prototype.
See Also:
HttpNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
HttpNet * httpCreateNet (MprDispatcher *dispatcher, struct HttpEndpoint *endpoint, int protocol, int flags)

Create a network object.

Description:
The network object defines the underlying network connection over which HttpStream connection streams will be multiplexed.
Parameters:
dispatcherEvent MprDispatcher object to serialize events for the network.
endpointServer-side HttpEndpoint object. Set to NULL for client-side.
protocolHTTP protocol to use by default. Set to 1 for HTTP/1 and 2 for HTTP/2.
flagsSet to HTTP_NET_ASYNC if you wish to use async I/O. Otherwise set to zero.
Returns:
A new network object.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpDestroyNet (HttpNet *net)

Destroy the network object.

Description:
This call closes the network socket, destroys the connection dispatcher, disconnects the HttpStream objects and removes the network from the HttpHost list of networks. All active stream connections (HttpStream) will also be destroyed. Thereafter, the garbage collector can reclaim all memory. It may be called by client connections at any time from a top-level event running on the connection's dispatcher. Server-side code should not explicitly destroy the connection as it will be done automatically via httpIOEvent.
Parameters:
netHttpNet object created via httpCreateNet
API Stability:
Internal.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpEnableNetEvents (HttpNet *net)

Enable network events.

Description:
Network events are automatically disabled upon receipt of an I/O event on a network connection. This permits a network to process the I/O without fear of interruption by another I/O event. At the completion of processing of the I/O request, the network should be re-enabled via httpEnableNetEvents. This call is made for requests in httpIOEvent. Client-side networks may need to enable network events if they are running in async mode and encounter a blocking condition.
Parameters:
netHttpNet Network object created via httpCreateNet
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
bool httpGetAsync (HttpNet *net)

Get the async mode value for the network.

Parameters:
netHttpNet object created via httpCreateNet
Returns:
True if the Network is in async mode.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
cchar * httpGetProtocol (HttpNet *net)

Get the Http protocol variant for this network connection.

Parameters:
netHttpNet Network object created via httpCreateNet
Returns:
HTTP/1.0, HTTP/1.1 or HTTP/2.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpIOEvent (struct HttpNet *net, MprEvent *event)

Respond to a HTTP I/O event.

Description:
This routine responds to I/O events. If any readable data is present, it allocates a standard sized packet and reads data into this packet and passes to the input queue pipeline.
Parameters:
netHttpNet object created via httpCreateNet
eventEvent structure.
API Stability:
Internal.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpNetError (HttpNet *net, cchar *fmt, ...)

Error handling for the network.

Description:
The httpNetError call is used to flag the current network as failed. If httpNetError is called multiple times, those calls are ignored and only the first call to httpNetError has effect. This call will close all network streams and discard all data in output pipeline queues.
Parameters:
netHttpNet object created via httpCreateNet
fmtPrintf style formatted string.
...Arguments for fmt.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpNetTimeout (HttpNet *net)

Schedule a network connection timeout event on a network.

Description:
This call schedules a timeout event to run serialized on the network's dispatcher. When run, it will cancel all current requests on the network, disconnect the socket and issue an error to the error log. This call is normally invoked by the httpTimer which runs regularly to check for timed out requests.
Parameters:
netHttpNet Network object created via httpCreateNet
API Stability:
Internal.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
bool httpQueuesNeedService (HttpNet *net)

Test if the network queues need service.

Parameters:
netHttpNet object created via httpCreateNet
Returns:
True if there are queues that require servicing.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpReturnNet (HttpNet *net)

Return a borrowed a network connection.

Description:
Returns a borrowed network object back to the Http engine. This ends the exclusive loan of the network so that the current request can be completed. It also enables I/O events based on the current state of the network.

While the network is borrowed, you must not access the network using foreign / non-MPR threads. Use mprCreateEvent to schedule an event to run on the network's event dispatcher. This is essential to serialize access to the network object.

You should only call this routine (once) after calling httpBorrowNet.

Parameters:
netHttpNet object created via httpCreateNet
API Stability:
Prototype.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
bool httpServiceQueues (HttpNet *net, int flags)

Service pipeline queues to flow data.

Description:
This routine should not be called by handlers, filters or user applications. It should only be called by the http pipeline and support routines.
Parameters:
netHttpNet object created via httpCreateNet
flagsSet to HTTP_BLOCK to yield for GC if due.
Returns:
True if work was done servicing queues.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpSetAsync (HttpNet *net, bool async)

Set the async mode value for the network.

Parameters:
netHttpNet object created via httpCreateNet
asyncSet to 1 to enable async mode.
Returns:
True if the network is in async mode.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpSetIOCallback (struct HttpNet *net, HttpIOCallback fn)

Define an I/O callback for network connections.

Description:
The I/O callback is invoked when I/O events are detected on the network. The default I/O callback is httpIOEvent
Parameters:
netHttpNet object created via httpCreateNet
fnCallback function to invoke.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetNetContext, httpStealSocket, httpStealSocketHandle
void httpSetNetContext (HttpNet *net, void *context)

Set the network context object.

Parameters:
netHttpNet object created via httpCreateNet
contextNew context object. Must be a managed memory reference.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpStealSocket, httpStealSocketHandle
void httpSetNetProtocol (HttpNet *net, int protocol)

Set the Http protocol variant for this network connection.

Description:
Set the Http protocol variant to use.
Parameters:
netHttpNet Network object created via httpCreateNet
protocolInteger representing the protocol variant. Valid values are: 0 for HTTP/1.0, 1 for HTTP/1.1 and 2 for HTTP/2.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket, httpStealSocketHandle
MprSocket * httpStealSocket (HttpNet *net)

Steal a socket from a network.

Description:
Steal the MprSocket object from a network so the caller can assume total responsibility for the socket. This routine returns a clone of the networks's socket object with the socket O/S handle. The handle is removed from the networks's socket object. The network retains ownership of the original MprSocket object sans the socket handle. This is done to preserve the HttpNetwork.sock object but remove the socket handle from its management.

Note: The current request is aborted and queue data is discarded. After calling, the normal Appweb request and inactivity timeouts will not apply to the returned socket object. It is the callers responsibility to call mprCloseSocket on the returned MprSocket when ready.

An alternative to this routine is httpBorrowNet which temporarily loans the network socket and secures it from destruction.
Parameters:
netHttpNet object created via httpCreateNet
Returns:
A clone of the network's MprSocket object with the socket handle.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocketHandle
Socket httpStealSocketHandle (HttpNet *net)

Steal the O/S socket handle from the network socket object.

Description:
This removes the O/S socket handle from active management by the network. After calling, normal request and inactivity timeouts will apply to the network, but will not disturb the underlying actual socket handle. It is the callers responsibility to call close() on the socket handle when ready.
Parameters:
netHttpNet object created via httpCreateNet
Returns:
The O/S Socket handle.
API Stability:
Evolving.
See Also:
HttpNet, httpConnectNet, httpCreateNet, httpDestroyNet, httpEnableNetEvents, httpGetAsync, httpGetProtocol, httpIOEvent, httpNetError, httpNetTimeout, httpServiceQueues, httpSetAsync, httpSetIOCallback, httpSetNetContext, httpStealSocket

HttpPacket

HttpPacket

Packet object.

Description:
The request/response pipeline sends data and control information in HttpPacket objects. The output stream typically consists of a HEADER packet followed by zero or more data packets and terminated by an END packet. If the request has input data, the input stream consists of one or more data packets followed by an END packet.

Packets contain data and optional prefix or suffix headers. Packets can be split, joined, filled, or emptied. The pipeline stages will fill or transform packet data as required.
See Also:
HttpFillProc, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
API Stability:
Internal.
Fields:
MprBuf *content Chunk content.
void *data Managed data reference.
MprOffepos Data position in entity (file).
MprOffesize Data size in entity (file).
HttpFillProcfill Callback to fill packet with data.
uintflags Packet flags.
uintlast Last packet in a message - used by web sockets.
struct HttpPacket *next Next packet in chain.
MprBuf *prefix Prefix message to be emitted before the content.
struct HttpStream *stream Reference to owning stream.
uinttype Packet type extension.
void httpAdjustPacketEnd (HttpPacket *packet, MprOff size)

Adjust the packet end position.

Description:
This adjusts the packet content by the given size. The packet length (size) is decremented by the requested amount. If the packet describes entity data, the Packet.esize field is reduced by the requested size amount. If the packet has actual data buffered in Packet.content, the content buffer end position is reduced by by the size amount.
Parameters:
packetPacket to modify.
sizeSize to adjust packet end position.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
void httpAdjustPacketStart (HttpPacket *packet, MprOff size)

Adjust the packet starting position.

Description:
This adjusts the packet content by the given size. The packet position is incremented by start and the packet length (size) is decremented. If the packet describes entity data, the given size amount to the Packet.epos and decrements the Packet.esize fields. If the packet has actual data buffered in Packet.content, the content buffer start is incremeneted by the size amount.
Parameters:
packetPacket to modify.
sizeSize to add to the packet current position.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpClonePacket (HttpPacket *orig)
HttpPacket * httpCreateDataPacket (ssize size)

Create a data packet.

Description:
Create a packet and set the HTTP_PACKET_DATA flag Data packets convey data through the response pipeline.
Parameters:
sizeSize of the package data storage.
Returns:
HttpPacket object.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreateEndPacket (void )

Create an end-of-stream packet.

Description:
Create an end-of-stream packet and set the HTTP_PACKET_END flag. The end pack signifies the end of data. It is used on both incoming and outgoing streams through the request/response pipeline.
Returns:
HttpPacket object.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreateEntityPacket (MprOff pos, MprOff size, HttpFillProc fill)

Create an entity data packet.

Description:
Create an entity packet and set the HTTP_PACKET_DATA flag. Entity packets describe the resource (entity) to send to the client and provide a HttpFillProc procedure used to fill packets with data from the entity.
Parameters:
posPosition within the entity for packet data.
sizeSize of the entity data.
fillHttpFillProc callback to supply the entity data.
Returns:
HttpPacket object.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreateHeaderPacket (void )

Create a response header packet.

Description:
Create a response header packet and set the HTTP_PACKET_HEADER flag. A header packet is used by the pipeline to hold the response headers.
Returns:
HttpPacket object.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreatePacket (ssize size)

Create a data packet.

Description:
Create a packet of the required size.
Parameters:
sizeSize of the package data storage.
Returns:
HttpPacket object.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
ssize httpGetPacketContents (HttpPacket *packet)

Get the packet data contents.

Description:
Get the packet content reference. This is an MprBuf object.
Parameters:
packetPacket to examine.
Returns:
MprBuf reference or zero if there are not contents.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
ssize httpGetPacketLength (HttpPacket *packet)

Get the length of the packet data contents.

Description:
Get the content length of a packet. This does not include the prefix or virtual data length just the pure buffered data contents.
Parameters:
packetPacket to examine.
Returns:
Count of bytes contained by the packet.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
char * httpGetPacketStart (HttpPacket *packet)
char * httpGetPacketString (HttpPacket *packet)

Get the packet data contents as a string.

Description:
Get the packet content reference. The packet contents will be null terminated.
Parameters:
packetPacket to examine.
Returns:
A reference to the start of the packet contents.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
bool httpIsLastPacket (HttpPacket *packet)

Test if the packet is the last in a logical message.

Description:
Useful for WebSockets to test if the packet is the last frame in a message.
Parameters:
packetPacket to examine.
Returns:
True if the packet is the last in a message.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
int httpJoinPacket (HttpPacket *packet, HttpPacket *other)

Join two packets.

Description:
Join the contents of one packet to another by copying the data from the other packet into the first packet.
Parameters:
packetDestination packet.
otherOther packet to copy data from.
Returns:
"Zero" if successful, otherwise a negative Mpr error code.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpSplitPacket (HttpPacket *packet, ssize offset)

Split a data packet.

Description:
Split a data packet at the specified offset. Packets may need to be split so that downstream stages can digest their contents. If a packet is too large for the queue maximum size, it should be split. When the packet is split, a new packet is created containing the data after the offset. Any suffix headers are moved to the new packet. NOTE: when splitting packets, the HttpPacket.content reference may be modified.
Parameters:
packetPacket to split.
offsetLocation in the original packet at which to split. This is an offset relative to the current 'start' read position not the beginning of the packet content buffer.
Returns:
New HttpPacket object containing the data after the offset. No need to free, unless you have a very long running request. Otherwise the packet memory will be released automatically when the request completes.
API Stability:
Stable.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpAdjustPacketEnd, httpAdjustPacketStart, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpIsLastPacket, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext

HttpQueue

HttpQueue

Queue object.

Description:
The request pipeline consists of a full-duplex pipeline of stages. Each stage has two queues, one for outgoing data and one for incoming. A HttpQueue object manages the data flow for a request stage and has the ability to queue and process data, manage flow control, and schedule packets for service.

Queue's provide open, close, put, and service methods. These methods manage and respond to incoming packets. A queue can respond immediately to an incoming packet by processing or dispatching a packet in its put() method. Alternatively, the queue can defer processing by queueing the packet on it's service queue and then waiting for it's service() method to be invoked.

If a queue does not define a put() method, the default put() method will be used which queues data onto the service queue. The default incoming put() method joins incoming packets into a single packet on the service queue.

Data flows downstream from one queue to the next queue linked via the nextQ field.
See Also:
HttpPacket, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
API Stability:
Internal.
Fields:
HttpQueueCloseclose Close the queue.
ssizecount Bytes in queue (Does not include virt packet data).
intdirection Flow direction.
HttpPacket *first First packet in queue (singly linked).
intflags Queue flags.
MprOffioCount Count of bytes in iovec including file I/O.
intioFile Sending a file.
intioIndex Next index into iovec.
MprOffioPos Position in file.
HttpPacket *last Last packet in queue (tail pointer).
ssizelow Low water mark for flow control.
ssizemax Advisory maxiumum queue size.
cchar *name Queue name for debugging.
struct HttpNet *net Network connection owning this queue.
struct HttpQueue *nextQ Downstream queue for next stage.
HttpQueueOpenopen Open the queue.
ssizepacketSize Maximum acceptable packet size.
struct HttpQueue *pair Queue for the same stage in the opposite direction.
struct HttpQueue *prevQ Upstream queue for prior stage.
HttpQueueDataput Callback to receive a packet.
void *queueData Stage instance data - must be a managed reference.
struct HttpQueue *scheduleNext Next linkage when queue is on the service queue.
struct HttpQueue *schedulePrev Previous linkage when queue is on the service queue.
HttpQueueServiceservice Service the queue.
intservicing Currently being serviced.
struct HttpStage *stage Stage owning this queue.
HttpQueueStartstart Start the queue.
void *staticData Stage instance data - must be an unmanaged reference.
struct HttpStream *stream Stream owning this queue may be null.
ssizewindow HTTP/2 flow control window size.
void httpDiscardQueueData (HttpQueue *q, bool removePackets)

Discard all data from the queue.

Description:
Discard data from the queue. If removePackets (not yet implemented) is "true", then remove the packets. Oherwise, just discard the data and preserve the packets.
Parameters:
qQueue reference.
removePacketsIf "true", the data packets will be removed from the queue.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpFlushQueue (HttpQueue *q, int flags)

Flush queue data.

Description:
This initiates writing buffered data (flushes) by scheduling the queue and servicing the queues.

If blocking mode is selected, all queues will be immediately serviced and the call may block while output drains. If non-blocking, the queues will be serviced but the call will not block nor yield. In blocking mode, this routine may invoke mprYield before it blocks to consent for the garbage collector to trun. Callers must ensure they have retained all required temporary memory before invoking this routine.

This routine when used with HTTP_BLOCK should never be used in filters, connectors or by handlers outside their open, close, ready, start and writable callbacks.
Parameters:
qQueue to flush.
flagsIf set to HTTP_BLOCK, this call will block until the data has drained through the network connector.
Returns:
"True" if there is room for more data in the queue after flushing.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
HttpPacket * httpGetPacket (struct HttpQueue *q)

Get the next packet from a queue.

Description:
Get the next packet. This will remove the packet from the queue and adjust the queue counts accordingly. If the queue is full and upstream queues are blocked, they will be enabled.
Parameters:
qQueue reference.
Returns:
The packet removed from the queue.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
ssize httpGetQueueRoom (HttpQueue *q)
bool httpIsEof (struct HttpStream *stream)

Test if the connection has received all incoming content.

Description:
This tests if the connection is at an "End of File condition.
Parameters:
streamHttpStream object created via httpCreateStream
Returns:
"True" if all Receive content has been received.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpIsPacketTooBig (struct HttpQueue *q, HttpPacket *packet)

Test if a packet is too big.

Description:
Test if a packet is too big to fit downstream. If the packet content exceeds the downstream queue's maximum or exceeds the downstream queue's requested packet size then this routine will return "true".
Parameters:
qQueue reference.
packetPacket to test.
Returns:
"True" if the packet is too big for the downstream queue.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpIsQueueEmpty (HttpQueue *q)

Determine if the queue is empty.

Description:
Determine if the queue has no packets queued. This does not test if the queue has no data content.
Parameters:
qQueue reference.
Returns:
"True" if there are no packets queued.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpIsQueueSuspended (HttpQueue *q)
void httpJoinPacketForService (struct HttpQueue *q, HttpPacket *packet, bool serviceQ)

Join a packet onto the service queue.

Description:
Add a packet to the service queue. If the queue already has data, then this packet will be joined (aggregated) into the existing packet. If serviceQ is true, the queue will be scheduled for service.
Parameters:
qQueue reference.
packetPacket to join to the queue.
serviceQIf true, schedule the queue for service.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpJoinPackets (HttpQueue *q, ssize size)

Join packets together.

Description:
This call joins data packets on the given queue into a single packet. The given size specifies the maximum size of data to be joined. The maximum size may also limited by the downstream queue maximum packet size.
Parameters:
qQueue to examine.
sizeThe maximum-sized packet that will be created by joining queue packets is the minimum of the given size and the downstream queues maximum packet size. Note: this routine will not split packets and so the maximum is advisory only.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpNextQueueFull (HttpQueue *q)
void httpPutBackPacket (struct HttpQueue *q, HttpPacket *packet)

Put a packet back onto a queue.

Description:
Put the packet back onto the front of the queue. The queue's put() method is not called. This is typically used by the queue's service routine when a packet cannot complete processing.
Parameters:
qQueue reference.
packetPacket to put back.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpPutForService (struct HttpQueue *q, HttpPacket *packet, bool serviceQ)

Put a packet into the service queue for deferred processing.

Description:
Add a packet to the service queue. If serviceQ is true, the queue will be scheduled for service.
Parameters:
qQueue reference.
packetPacket to join to the queue.
serviceQIf true, schedule the queue for service.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpPutPacket (struct HttpQueue *q, HttpPacket *packet)

Put a packet to the queue.

Description:
The packet is passed to the queue by invoking its put() callback. Note the receiving queue may immediately process the packet or it may choose to defer processing by putting to its service queue.
Parameters:
qQueue reference

Note: the garbage collector may run while calling httpSendBlock to reclaim unused packets. It is essential that all required memory be retained by a relevant manager calling mprMark as required.
packetPacket to put.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpPutPacketToNext (struct HttpQueue *q, HttpPacket *packet)

Put a packet to the next queue downstream.

Description:
Put a packet onto the next downstream queue by calling the downstream queue's put() method. Note the receiving queue may immediately process the packet or it may choose to defer processing by putting to its service queue.
Parameters:
qQueue reference

Note: the garbage collector may run while calling httpSendBlock to reclaim unused packets. It is essential that all required memory be retained by a relevant manager calling mprMark as required.
qQueue reference. The packet will not be queued on this queue, but rather on the queue downstream.
packetPacket to put.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpRemoveQueue (HttpQueue *q)

Remove a queue.

Description:
Remove a queue from the request/response pipeline. This will remove a queue so that it does not participate in the pipeline, effectively removing the processing stage from the pipeline. This is useful to remove unwanted filters and to speed up pipeline processing.
Parameters:
qQueue reference.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
HttpPacket * httpResizePacket (struct HttpQueue *q, HttpPacket *packet, ssize size)

Resize a packet.

Description:
Resize a packet, if required, so that it fits in the downstream queue. This may split the packet if it is too big to fit in the downstream queue. If it is split, the tail portion is put back on the queue.
Parameters:
qQueue reference. The q->nextQ will be examined to see if the packet will fit.
packetPacket to put.
sizeIf size is > 0, then also ensure the packet is not larger than this size.
Returns:
Zero if the packet is not resized. Otherwise return the tail packet that was put back onto the queue.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpResumeQueue (HttpQueue *q)

Resume a queue.

Description:
Resume a queue for service and schedule it to run. This will cause the service routine to run as soon as possible. This is normally called automatically called by the pipeline when downstream congestion has cleared.
Parameters:
qQueue reference.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpScheduleQueue (HttpQueue *q)
void httpSetQueueLimits (HttpQueue *q, HttpLimits *limits, ssize packetSize, ssize low, ssize max, ssize window)

Set a queue's max packetSize and flow control low, max and window thresholds.

Description:
If size parameters are set to -1, default values from the limits are used.
Parameters:
qQueue reference.
limitsDefault limits to use if other arguments are not provided.
packetSizeThe default maximum packet size.
lowThe low water mark. Typically set to packet size by default.
maxThe high water mark. Set by default to packetSize * 4.
windowHTTP/2 flow control window size. Must be at least HTTP_DEFAULT_WINDOW_SIZE.
API Stability:
Evolving.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
void httpSuspendQueue (HttpQueue *q)

Suspend a queue.

Description:
Suspended a queue so that it will not be scheduled for service. The pipeline will will automatically call httpResumeQueue when the downstream queues are less congested.
Parameters:
qQueue reference.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpWillNextQueueAcceptPacket (HttpQueue *q, HttpPacket *packet)

Determine if the downstream queue will accept this packet.

Description:
Test if the downstream queue will accept a packet. The packet will be resized, if required, in an attempt to get the downstream queue to accept it. If the downstream queue is full, disable this queue and mark the downstream queue as full, and service it immediately to try to relieve the congestion.
Parameters:
qQueue reference.
packetPacket to put.
Returns:
"True" if the downstream queue will accept the packet. Use httpPutPacketToNext to send the packet downstream.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpWillNextQueueAcceptSize (HttpQueue *q, ssize size)

Determine if the downstream queue will accept a certain amount of data.

Description:
Test if the downstream queue will accept data of a given size.
Parameters:
qQueue reference.
sizeSize of data to test for.
Returns:
"True" if the downstream queue will accept the given sized data.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock, httpWriteString
bool httpWillQueueAcceptPacket (HttpQueue *q, HttpQueue *nextQ, HttpPacket *packet)

Determine if the given queue will accept this packet.

Description:
Test if the queue will accept a packet. The packet will be resized, if split is true, in an attempt to get the downstream queue to accept it.
Parameters:
qQueue reference.
nextQNext (downstream) queue reference.
packetPacket to put.
Returns:
"True" if the queue will accept the packet.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
ssize httpWrite (HttpQueue *q, cchar *fmt, ...)

Write a formatted string.

Description:
Write a formatted string of data into packets onto the end of the queue. Data packets will be created as required to store the write data. This call always accepts all the data and will buffer as required. This call may block waiting for the downstream queue to drain if it is or becomes full. Data written after httpFinalizeOutput or httpError is called will be ignored.

Handlers may only call httpWrite in their open, close, ready, start and writable callbacks as these are the only callbacks permitted to block. If a handler needs to write in other callbacks, it should use httpWriteBlock and use the HTTP_NON_BLOCK or HTTP_BUFFER flags.

Filters and connectors must never call httpWrite as it may block.
Parameters:
qQueue reference.
fmtPrintf style formatted string.
...Arguments for fmt.
Returns:
A count of the bytes actually written.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWriteBlock, httpWriteString
ssize httpWriteBlock (HttpQueue *q, cchar *buf, ssize size, int flags)

Write a block of data to the queue.

Description:
Write a block of data onto the end of the queue. This will queue the data and may initiaite writing to the connection if the queue is full. Data will be appended to last packet in the queue if there is room. Otherwise, data packets will be created as required to store the write data.

This call operates in buffering mode by default unless either the HTTP_BLOCK OR HTTP_NON_BLOCK flag is specified. When blocking, the call will either accept and write all the data or it will fail, it will never return "short" with a partial write.

In blocking mode (HTTP_BLOCK), it block for up to the inactivity timeout specified in the stream->limits->inactivityTimeout value. In blocking mode, this routine may invoke mprYield before blocking to consent for the garbage collector to run. Callers must ensure they have retained all required temporary memory before invoking this routine.

In non-blocking mode (HTTP_NON_BLOCK), the call may return having written fewer bytes than requested.

In buffering mode (HTTP_BUFFER), the data is always absorbed without blocking and queue size limits are ignored. In buffering mode, this routine may invoke mprYield if required to consent for the garbage collector to run. Callers must ensure they have retained all required temporary memory before invoking this routine.

Data written after calling httpFinalize, httpFinalizeOutput or httpError will be discarded.
Parameters:
qQueue reference.
bufBuffer containing the write data.
sizeof the data in buf.
flagsSet to HTTP_BLOCK for blocking operation or HTTP_NON_BLOCK for non-blocking. Set to HTTP_BUFFER to buffer the data if required and never block. Set to zero will default to HTTP_BUFFER.
Returns:
The size value if successful or a negative MPR error code.
API Stability:
Evolving.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteString
ssize httpWriteString (HttpQueue *q, cchar *s)

Write a string of data to the queue.

Write a safe string of data to the queue
Description:
Write a string of data into packets onto the end of the queue. Data packets will be created as required to store the write data. This call may block waiting for the downstream queue to drain if it is or becomes full. Data written after httpFinalizeOutput or httpError is called will be ignored.
Parameters:
qQueue reference.
sString containing the data to write.
Returns:
A count of the bytes actually written.
API Stability:
Stable.
Description:
This will escape any HTML sequences before writing the string into packets onto the end of the queue. Data packets will be created as required to store the write data. This call may block waiting for the downstream queue to drain if it is or becomes full. Data written after httpFinalizeOutput or httpError is called will be ignored.
Parameters:
qQueue reference.
sString containing the data to write.
Returns:
A count of the bytes actually written.
API Stability:
Stable.
See Also:
HttpPacket, HttpQueue, HttpStream, httpDiscardQueueData, httpFlushQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpIsQueueSuspended, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpResumeQueue, httpScheduleQueue, httpSetQueueLimits, httpSuspendQueue, httpWillNextQueueAcceptSize, httpWillQueueAcceptPacket, httpWrite, httpWriteBlock

HttpRange

HttpRange

Content range structure.

Range: 0, 49 First 50 bytes Range: -1, -50 Last 50 bytes Range: 1, -1 Skip first byte then select content to the end.
See Also:
API Stability:
Internal.
Fields:
MprOffend End byte of range + 1.
MprOfflen Redundant range length.
struct HttpRange *next Next range.
MprOffstart Start of range.

HttpRoute

HttpRoute

Route Control.

Description:
Configuration is not thread safe and must occur at initialization time when the application is single threaded. If the configuration is modified when the application is multithreaded, all requests must be first be quiesced.
See Also:
httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
API Stability:
Internal.
Fields:
HttpAuth *auth Per route block authentication.
intautoDelete Automatically delete uploaded files.
MprList *caching Items to cache.
cchar *clientConfig Configuration to send to the client.
MprList *conditions Route conditions.
MprJson *config Configuration file content.
HttpStage *connector Network connector to use.
void *context Hosting context (Appweb == EjsPool).
cchar *cookie Cookie name for session data.
intcorsAge Age in seconds of the pre-flight authorization.
boolcorsCredentials Whether to emit an Access-Control-Allow-Credentials.
cchar *corsHeaders Headers to add for Access-Control-Expose-Headers.
cchar *corsMethods Methods to add for Access-Control-Allow-Methods.
cchar *corsOrigin CORS permissible client origins.
MprHash *data Hash of extra data configuration.
cchar *database Name of database for route.
booldebug Application running in debug mode.
char *defaultLanguage Default language.
cchar *documents Documents directory.
char *envPrefix Environment strings prefix.
void *eroute Extended route information for handler (only).
boolerror Parse or runtime error.
MprHash *errorDocuments Set of error documents to use on errors.
MprHash *extensions Hash of handlers by extensions.
intflags Route flags.
HttpStage *handler Fixed handler.
MprList *handlers List of handlers for this route.
MprList *headers Response header values.
cchar *home Home directory for configuration files.
struct HttpHost *host Owning host.
Http *http Http service object (copy of appweb->http).
boolignoreEncodingErrors Ignore UTF8 encoding errors.
MprList *indexes Directory index documents.
MprList *inputStages Input stages.
booljson Response format is json.
MprHash *languages Languages supported.
MprTickslifespan Default lifespan for all cache items in route.
HttpLimits *limits Host resource limits.
MprHash *map Map of alternate extensions (gzip|minified).
MprHash *methods Matching HTTP methods.
MprHash *mimeTypes Hash table of mime types (key is extension).
cchar *mode Application run profile mode (debug|release).
intnextGroup Next route with a different startWith.
char *optimizedPattern Processed pattern (excludes prefix).
MprList *outputStages Output stages.
MprList *params Matching param field data.
struct HttpRoute *parent Parent route.
char *pattern Original matching URI pattern for the route (includes prefix).
void *patternCompiled Compiled pattern regular expression (not alloced).
char *prefix Application scriptName prefix. Set to '' for '/'. Always set.
ssizeprefixLen Prefix length.
intrenameUploads Rename uploaded files.
MprList *requestHeaders Required request header values.
cchar *responseFormat Client response format.
intresponseStatus Response status code.
char *script Startup script for handlers serving this route.
char *scriptPath Startup script path for handlers serving this route.
cchar *source Final source for route target.
cchar *sourceName Source name for route target.
struct MprSsl *ssl SSL configuration.
char *startSegment First starting literal segment of pattern.
ssizestartSegmentLen Prefix length.
char *startWith Starting literal portion of pattern.
ssizestartWithLen Length of startWith.
char *target Route target details.
char *targetRule Target rule.
MprList *tokens Tokens in pattern, {name}.
char *tplate URI template for forming links based on this route (includes prefix).
HttpTrace *trace Per-route tracing configuration.
MprList *updates Route and request updates.
MprHash *vars Route variables. Used to expand Path ${token} refrerences.
MprTickswebSocketsPingPeriod Time between pings (msec).
char *webSocketsProtocol WebSockets sub-protocol.
intworkers Number of workers to use for this route.
HttpParseCallback httpAddConfig (cchar *key, HttpParseCallback callback)
void httpAddPermResource (HttpRoute *parent, cchar *resource)
void httpAddResource (HttpRoute *parent, cchar *resource)

Add routes for a resource.

Description:
This routing adds a set of RESTful routes for a resource. It will add the following routes:
NameMethodPatternAction
createPOST/NAME(/)*$create
editGET/NAME/edit$edit
getGET/NAME$get
initGET/NAME/init$init
updatePUT/NAME$update
removeDELETE/NAME$remove
default*/NAME/{action}$cmd-${action}
Parameters:
parentParent route from which to inherit configuration.
resourceResource name. This should be a lower case, single word, alphabetic resource name.
API Stability:
Evolving.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddResourceGroup (HttpRoute *parent, cchar *resource)

Add routes for a group of resources.

Description:
This routing adds a set of RESTful routes for a resource group. It will add the following routes:
NameMethodPatternAction
createPOST/NAME(/)*$create
editGET/NAME/{id=[0-9]+}/edit$edit
getGET/NAME/{id=[0-9]+}$get
initGET/NAME/init$init
listGET/NAME(/)*$list
removeDELETE/NAME/{id=[0-9]+}$remove
updatePUT/NAME/{id=[0-9]+}$update
actionPOST/NAME/{action}/{id=[0-9]+}$${action}
default*/NAME/{action}$cmd-${action}
Parameters:
parentParent route from which to inherit configuration.
resourceResource name. This should be a lower case, single word, alphabetic resource name.
API Stability:
Evolving.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
HttpRoute * httpAddRestfulRoute (HttpRoute *parent, cchar *methods, cchar *pattern, cchar *target, cchar *resource)

Define a RESTful route.

Description:
This creates a restful route and then configures it using the given parameters. The route is finalized and added to the parent host.
Parameters:
parentParent route from which to inherit configuration.
methodsHttp methods for which this route is active.
patternMatching URI pattern for which this route will qualify.
targetRoute target string expression. This is used by handlers to determine the physical or virtual resource to serve.
resourceResource basename to use when constructing a source file name.
Returns:
Created route.
API Stability:
Evolving.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpAddRouteCondition (HttpRoute *route, cchar *name, cchar *details, int flags)

Add a route condition.

Description:
A route condition is run after matching the route pattern. For a route to be accepted, all conditions must match. Route conditions are built-in rules that can be applied to routes.
Parameters:
routeRoute to modify.
nameCondition rule to add. Supported conditions are: "auth", "missing", "directory", "exists", and "match". The "auth" rule is used internally to implement basic and digest authentication.

The "missing" rule tests if the target filename is missing. The "missing" rule takes no arguments.

The "directory" rule tests if the condition argument is a directory. The form of the "directory" rule is: "directory pathString". For example: "directory /stuff/${request:pathInfo}.txt"

The "exists" rule tests if the condition argument is present in the file system. The form of the "exists" rule is: "exists pathString". For example: "exists ${request.filename}.gz",

The match directory tests a regular expression pattern against the rest of the condition arguments. The form of the match rule is: "match RegExp string". For example: "match https ${request.scheme}".
detailsCondition parameters. See httpSetRouteTarget for a list of the token values that can be included in the condition rule details.
flagsSet to HTTP_ROUTE_NOT to negate the condition test.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Evolving.
See Also:
HttpRoute, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteErrorDocument (HttpRoute *route, int status, cchar *uri)
int httpAddRouteFilter (HttpRoute *route, cchar *name, cchar *extensions, int direction)

Add a route filter.

Description:
This configures the route pipeline by adding processing filters for a request. must match. Route conditions are built-in rules that can be applied to routes.
Parameters:
routeRoute to modify.
nameFilter name to add.
extensionsRequest extensions for which the filter will be run. A request extension may come from the URI if present or from the corresponding filename.
directionSet to HTTP_STAGE_TX for transmit direction and HTTP_STAGE_RX for receive data flow.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpAddRouteHandler (HttpRoute *route, cchar *name, cchar *extensions)

Add a route handler.

Description:
This configures the route pipeline by adding the given handler. Must only be called at initialization time for the route.
Parameters:
routeRoute to modify.
nameFilter name to add.
extensionsRequest extensions for which the handler will be selected. A request extension may come from the URI if present or from the corresponding filename.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteIndex (HttpRoute *route, cchar *path)

Set the route index document.

Description:
Set the name of the index document to serve. Index documents may be served when the request corresponds to a directory on the file system.
Parameters:
routeRoute to modify.
pathPath name to the index document. If the path is a relative path, it may be joined to the route directory to create an absolute path.
Returns:
A reference to the route data. Otherwise return null if the route data for the given key was not found.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpAddRouteLanguageDir (HttpRoute *route, cchar *language, cchar *path)

Add a route language directory.

Description:
This configures the route pipeline by adding the given language content directory. When creating filenames for matching requests, the language directory is prepended to the request filename.
Parameters:
routeRoute to modify.
languageLanguage symbolic name. For example: "en" for english.
pathFile system directory to contain content for matching requests.
Returns:
Zero if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpAddRouteLanguageSuffix (HttpRoute *route, cchar *language, cchar *suffix, int flags)

Add a route language suffix.

Description:
This configures the route pipeline by adding the given language for request processing. The language definition includes a suffix which will be added to the request filename.
Parameters:
routeRoute to modify.
languageLanguage symbolic name. For example: "en" for english.
suffixExtension suffix to add when creating filenames for the request. For example: "fr" to add to "index.html" could produce: "index.fr.html".
flagsSet to HTTP_LANG_BEFORE to insert the suffix before the filename extension. Set to HTTP_LANG_AFTER to append after the extension. For example: HTTP_LANG_AFTER would produce "index.html.fr".
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteMapping (HttpRoute *route, cchar *extensions, cchar *mappings)

Add a route mapping.

Description:
Route mappings will map the request filename by changing the default extension to the mapped extension. This is used primarily to select compressed content.
Parameters:
routeRoute to modify.
extensionsComma separated list of extensions to map. For example: "css,html,js,less,txt,xml" Set to "*" or the empty string to match all extensions.
mappingsList of new file extensions to consider. This may include a "${1}" token to replace the previous extension. The extensions are searched in order and the first matching extensions for which there is an existing file will be selected. For example: "${1}.gz, min.${1}.gz, min.${1}".
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteMethods (HttpRoute *route, cchar *methods)
void httpAddRouteParam (HttpRoute *route, cchar *field, cchar *value, int flags)
void httpAddRouteRequestHeaderCheck (HttpRoute *route, cchar *header, cchar *value, int flags)
void httpAddRouteResponseHeader (HttpRoute *route, int cmd, cchar *header, cchar *value)

Add a response header.

Description:
This modifies the response header set.
Parameters:
routeRoute to modify.
cmdSet to HTTP_ROUTE_HEADER_ADD to add a header if it is not already present in the response header set. Set to HTTP_ROUTE_HEADER_REMOVE to remove a header. Set to HTTP_ROUTE_HEADER_SET to define a header and overwrite any prior values. Set to HTTP_ROUTE_HEADER_APPEND to append to an existing header value.
headerHeader field to interrogate.
valueHeader value that will match.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteSet (HttpRoute *route, cchar *set)
int httpAddRouteUpdate (HttpRoute *route, cchar *name, cchar *details, int flags)

Add a route update rule.

Description:
This configures the route pipeline by adding processing update rules for a request. Updates are built-in rules that can be applied to routes.
Parameters:
routeRoute to modify.
nameUpdate rule to add. Supported update rules include: "cmd", "field" and "lang".

The "cmd" rule is used to run external commands. For example: "cmd touch /tmp/filename".

The "param" rule is used to set values in the request param fields. For example: "param priority high".

The "lang" update rule is used internally to implement the various language options. See httpSetRouteTarget for a list of the token values that can be included in the condition rule details.
detailsUpdate rule parameters.
flagsReserved.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
HttpRoute * httpAddWebSocketsRoute (HttpRoute *route, cchar *action)
void httpClearRouteStages (HttpRoute *route, int direction)
HttpRoute * httpCreateActionRoute (HttpRoute *parent, cchar *pattern, HttpAction action)
HttpRoute * httpCreateAliasRoute (HttpRoute *parent, cchar *pattern, cchar *path, int status)

Create a route suitable for use as an alias.

Description:
The parent supplies the owning host for the route. A route is not added to its owning host until it is finalized by calling httpFinalizeRoute
Parameters:
parentParent route to inherit from.
patternPattern to match URIs.
pathFile system directory containing documents for this route.
statusHttp redirect status for matching requests. Set to zero if not using redirects.
Returns:
Allocated HttpRoute object.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
HttpRoute * httpCreateConfiguredRoute (struct HttpHost *host, int serverSide)
HttpRoute * httpCreateDefaultRoute (struct HttpHost *host)
HttpRoute * httpCreateInheritedRoute (HttpRoute *route)
HttpRoute * httpCreateRoute (struct HttpHost *host)
HttpRoute * httpDefineRoute (HttpRoute *parent, cchar *methods, cchar *pattern, cchar *target, cchar *source)

Define a route.

Description:
This creates a route and then configures it using the given parameters. The route is finalized and added to the parent host.
Parameters:
parentParent route from which to inherit configuration.
methodsHttp methods for which this route is active.
patternMatching URI pattern for which this route will qualify.
targetRoute target string expression. This is used by handlers to determine the physical or virtual resource to serve.
sourceSource file pattern containing the resource to activate or serve.
Returns:
Created route.
API Stability:
Stable.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDocuments, httpLink, httpLinkEx, httpLookupRouteErrorDocument, httpMakePath, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDocuments, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteVar, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpDefineRouteCondition (cchar *name, HttpRouteProc *proc)
HttpRouteSetProc httpDefineRouteSet (cchar *name, HttpRouteSetProc fn)
void httpDefineRouteTarget (cchar *name, HttpRouteProc *proc)
void httpDefineRouteUpdate (cchar *name, HttpRouteProc *proc)
cchar * httpExpandRouteVars (HttpRoute *route, cchar *str)
void httpFinalizeRoute (HttpRoute *route)
bool httpGetBoolToken (cchar *tok)
HttpRoute * httpGetDefaultRoute (HttpHost *host)
cchar * httpGetDir (HttpRoute *route, cchar *name)
HttpRoute * httpGetHostDefaultRoute (HttpHost *host)
void * httpGetRouteData (HttpRoute *route, cchar *key)

Get extra route data.

Description:
Routes can store extra configuration information indexed by key. This is used by handlers, filters, connectors and updates to store additional information on a per-route basis.
Parameters:
routeRoute to modify.
keyUnique string key to identify the data.
Returns:
A reference to the route data. Otherwise return null if the route data for the given key was not found.
See Also:
API Stability:
Stable.
cchar * httpGetRouteDocuments (HttpRoute *route)
cchar * httpGetRouteHome (HttpRoute *route)
cchar * httpGetRouteM