Components | Typedefs | Functions | Defines

Http - Embedthis Http Library

Components

Http Http service object.
HttpAuth Authorization.
HttpCache Cache Control.
HttpConn Http Connections.
HttpEndpoint Listening endpoints.
HttpHost Host Object.
HttpLimits Http limits.
HttpPacket Packet object.
HttpQueue Queue object.
HttpRange Content range structure.
HttpRoute Route Control.
HttpRx Http Rx.
HttpStage Pipeline Stages.
HttpTx Http Tx.
HttpUploadFile Upload File.
HttpUri URI management.

Functions

struct HttpConn*httpAccept(struct HttpEndpoint *endpoint)
 Internal APIs.
HttpConn*httpAcceptConn(HttpEndpoint *endpoint, MprEvent *event)
 Accept a new connection.
voidhttpAddCache(struct HttpRoute *route, cchar *methods, cchar *uris, cchar *extensions, cchar *types, MprTime clientLifespan, MprTime serverLifespan, int flags)
 Add caching for response content.
inthttpAddGroup(HttpAuth *auth, cchar *group, HttpAcl acl, bool enabled)
 Add a group.
voidhttpAddHeader(HttpConn *conn, cchar *key, cchar *fmt, ...)
 Add a header to the transmission using a format string.
voidhttpAddHeaderString(HttpConn *conn, cchar *key, cchar *value)
 Add a header to the transmission.
voidhttpAddHomeRoute(HttpRoute *parent)
 Add a route for the home page.
voidhttpAddHostToEndpoint(HttpEndpoint *endpoint, struct HttpHost *host)
 Add a host to an endpoint.
voidhttpAddOption(MprHash *options, cchar *field, cchar *value)
 Add an option to the options table.
voidhttpAddParams(HttpConn *conn)
 Add query and form body data to params.
voidhttpAddResource(HttpRoute *parent, cchar *resource)
 Add routes for a resource.
voidhttpAddResourceGroup(HttpRoute *parent, cchar *resource)
 Add routes for a group of resources.
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.
voidhttpAddRouteExpiry(HttpRoute *route, MprTime when, cchar *extensions)
 Cache response content in the client by extension.
voidhttpAddRouteExpiryByType(HttpRoute *route, MprTime when, cchar *mimeTypes)
 Cache response content in the client by mime type.
inthttpAddRouteFilter(HttpRoute *route, cchar *name, cchar *extensions, int direction)
 Add a route filter.
inthttpAddRouteHandler(HttpRoute *route, cchar *name, cchar *extensions)
 Add a route handler.
voidhttpAddRouteHeader(HttpRoute *route, cchar *header, cchar *value, int flags)
 Add a route header check.
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.
voidhttpAddRouteParam(HttpRoute *route, cchar *field, cchar *value, int flags)
 Add a route param check.
voidhttpAddRouteSet(HttpRoute *parent, cchar *set)
 Add a route set package.
inthttpAddRouteUpdate(HttpRoute *route, cchar *name, cchar *details, int flags)
 Add a route update rule.
voidhttpAddStaticRoute(HttpRoute *parent)
 Add a route for static content under a "static" directory.
voidhttpAddUploadFile(HttpConn *conn, cchar *id, HttpUploadFile *file)
 Add an Uploaded file.
inthttpAddUser(HttpAuth *auth, cchar *realm, cchar *user, cchar *password, bool enabled)
 Add a user.
inthttpAddUserToGroup(HttpAuth *auth, HttpGroup *gp, cchar *user)
 Add a user to a group.
inthttpAddUsersToGroup(HttpAuth *auth, cchar *group, cchar *users)
 Add users to a group.
voidhttpAdjustPacketEnd(HttpPacket *packet, MprOff size)
 Adjust the packet end position.
voidhttpAdjustPacketStart(HttpPacket *packet, MprOff size)
 Adjust the packet starting position.
voidhttpAppendHeader(HttpConn *conn, cchar *key, cchar *fmt, ...)
 Append a transmission header.
voidhttpAppendHeaderString(HttpConn *conn, cchar *key, cchar *value)
 Append a transmission header string.
voidhttpBackupRouteLog(HttpRoute *route)
 Backup the route log if required.
voidhttpCallEvent(HttpConn *conn, int mask)
 Call httpEvent with the given event mask.
voidhttpClearRouteStages(HttpRoute *route, int direction)
 Clear the pipeline stages for the route.
HttpHost*httpCloneHost(HttpHost *parent)
 Clone a host.
HttpPacket*httpClonePacket(HttpPacket *orig)
 Clone a packet.
HttpStage*httpCloneStage(Http *http, HttpStage *stage)
 Create a clone of an existing state.
HttpUri*httpCloneUri(HttpUri *base, int complete)
 Clone a URI.
voidhttpCloseConn(HttpConn *conn)
 Close a connection.
HttpUri*httpCompleteUri(HttpUri *uri, HttpUri *other)
 Complete the given URI.
inthttpConfigureNamedVirtualEndpoints(Http *http, cchar *ip, int port)
 Configure endpoints with named virtual hosts.
voidhttpConnTimeout(HttpConn *conn)
 Signal a connection timeout on a connection.
inthttpConnect(HttpConn *conn, cchar *method, cchar *uri)
 Connect to a server and issue Http client request.
voidhttpConnectorComplete(HttpConn *conn)
 Connector has completed sending the response.
voidhttpConsumeLastRequest(HttpConn *conn)
 Consume leftover data from the last request.
boolhttpContentNotModified(HttpConn *conn)
 Test if the content has not been modified.
Http*httpCreate()
 Create a Http service object.
HttpRoute*httpCreateAliasRoute(HttpRoute *parent, cchar *pattern, cchar *path, int status)
 Create a route suitable for use as an alias.
HttpAuth*httpCreateAuth()
 Create an authentication object.
voidhttpCreateCGIParams(HttpConn *conn)
 Create CGI parameters.
HttpEndpoint*httpCreateConfiguredEndpoint(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.
HttpConn*httpCreateConn(Http *http, struct HttpEndpoint *endpoint, MprDispatcher *dispatcher)
 Create a connection object.
HttpStage*httpCreateConnector(Http *http, cchar *name, int flags, MprModule *module)
 Create a connector stage.
HttpPacket*httpCreateDataPacket(ssize size)
 Create a data packet.
HttpRoute*httpCreateDefaultRoute(struct HttpHost *host)
 Create a default route for a host.
HttpPacket*httpCreateEndPacket()
 Create an eof 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(Http *http, cchar *name, int flags, MprModule *module)
 Create a filter stage.
HttpGroup*httpCreateGroup(HttpAuth *auth, cchar *name, HttpAcl acl, bool enabled)
 Create a new group.
HttpStage*httpCreateHandler(Http *http, cchar *name, int flags, MprModule *module)
 Create a request handler stage.
HttpPacket*httpCreateHeaderPacket()
 Create a response header packet.
HttpHost*httpCreateHost()
 Create a host.
HttpRoute*httpCreateInheritedRoute(HttpRoute *route)
 Create a route inherited from a parent route.
HttpLimits*httpCreateLimits(int serverSide)
 Create a new limits object.
HttpPacket*httpCreatePacket(ssize size)
 Create a data packet.
HttpRoute*httpCreateRoute(struct HttpHost *host)
 Create a route for a host.
voidhttpCreateRxPipeline(HttpConn *conn, struct HttpRoute *route)
 Create the receive request pipeline.
inthttpCreateSecret(Http *http)
 Create the Http secret data for crypto.
HttpStage*httpCreateStage(Http *http, cchar *name, int flags, MprModule *module)
 Create a connector stage.
HttpTx*httpCreateTx(HttpConn *conn, MprHash *headers)
 Create the tx object.
voidhttpCreateTxPipeline(HttpConn *conn, struct HttpRoute *route)
 Create the transmit request pipeline.
HttpUri*httpCreateUri(cchar *uri, int complete)
 Create and initialize a URI.
HttpUri*httpCreateUriFromParts(cchar *scheme, cchar *host, int port, cchar *path, cchar *reference, cchar *query, int complete)
 Create a URI from parts.
HttpUser*httpCreateUser(HttpAuth *auth, cchar *name, cchar *password, cchar *realm, bool enabled)
 Create a new user.
voidhttpDefaultOutgoingServiceStage(HttpQueue *q)
 Default outgoing data handling.
HttpRoute*httpDefineRoute(HttpRoute *parent, cchar *name, cchar *methods, cchar *pattern, cchar *target, cchar *source)
 Define a route.
voidhttpDefineRouteCondition(cchar *name, HttpRouteProc *proc)
 Define a route condition rule.
voidhttpDefineRouteTarget(cchar *name, HttpRouteProc *proc)
 Define a route target rule.
voidhttpDefineRouteUpdate(cchar *name, HttpRouteProc *proc)
 Define a route update rule.
voidhttpDestroy(Http *http)
 Destroy the Http service object.
voidhttpDestroyConn(HttpConn *conn)
 Destroy the connection object.
voidhttpDestroyEndpoint(HttpEndpoint *endpoint)
 Destroy the endpoint.
voidhttpDestroyPipeline(HttpConn *conn)
 Destroy the pipeline.
voidhttpDestroyTx(HttpTx *tx)
 Destroy the tx object.
inthttpDisableGroup(HttpAuth *auth, cchar *group)
 Disable a group.
voidhttpDisableQueue(HttpQueue *q)
 Disable a queue.
inthttpDisableUser(HttpAuth *auth, cchar *realm, cchar *user)
 Disable a user.
voidhttpDiscardData(HttpQueue *q, bool removePackets)
 Discard all data from the queue.
voidhttpDiscardTransmitData(HttpConn *conn)
 Discard buffered transmit pipeline data.
voidhttpDisconnect(HttpConn *conn)
 Disconnect the connection's socket.
voidhttpEaseLimits(HttpLimits *limits)
 Ease the limits.
voidhttpEnableConnEvents(HttpConn *conn)
 Enable connection events.
inthttpEnableGroup(HttpAuth *auth, cchar *group)
 Enable a group.
voidhttpEnableQueue(HttpQueue *q)
 Enable a queue.
voidhttpEnableTraceMethod(struct HttpLimits *limits, bool on)
 Enable use of the TRACE Http method by the object owning the limits object.
voidhttpEnableUpload(HttpConn *conn)
 Enable Multipart-Mime File Upload for this request.
inthttpEnableUser(HttpAuth *auth, cchar *realm, cchar *user)
 Enable a user.
voidhttpError(HttpConn *conn, int status, cchar *fmt, ...)
 Error handling for the connection.
voidhttpEvent(struct HttpConn *conn, MprEvent *event)
 Http I/O event handler.
voidhttpFinalize(HttpConn *conn)
 Finalize transmission of the http request.
voidhttpFinalizeRoute(HttpRoute *route)
 Finalize a route.
voidhttpFlush(HttpConn *conn)
 Flush tx data.
boolhttpFlushQueue(HttpQueue *q, bool block)
 Flush queue data.
voidhttpFollowRedirects(HttpConn *conn, bool follow)
 Follow redirctions.
voidhttpFormatError(HttpConn *conn, int status, cchar *fmt, ...)
 Format an error transmission.
ssizehttpFormatResponse(HttpConn *conn, cchar *fmt, ...)
 Format an alternate response.
ssizehttpFormatResponseBody(HttpConn *conn, cchar *title, cchar *fmt, ...)
 Format a response body.
voidhttpFormatResponseError(HttpConn *conn, int status, cchar *fmt, ...)
 Format an error response body.
ssizehttpFormatResponsev(HttpConn *conn, cchar *fmt, va_list args)
 Format an alternate response.
char*httpFormatUri(cchar *scheme, cchar *host, int port, cchar *path, cchar *ref, cchar *query, int complete)
 Format a URI.
inthttpGetAsync(HttpConn *conn)
 Get the async mode value for the connection.
ssizehttpGetChunkSize(HttpConn *conn)
 Get the preferred chunked size for transfer chunk encoding.
void*httpGetConnContext(HttpConn *conn)
 Get the connection context object.
void*httpGetConnHost(HttpConn *conn)
 Get the connection host object.
MprOffhttpGetContentLength(HttpConn *conn)
 Get the receive body content length.
void*httpGetContext(Http *http)
 Get the http context object.
cchar*httpGetCookies(HttpConn *conn)
 Get the request cookies.
char*httpGetDateString(MprPath *sbuf)
 Get the time as an ISO date string.
void*httpGetEndpointContext(HttpEndpoint *endpoint)
 Get the endpoint context object.
cchar*httpGetError(HttpConn *conn)
 Get the error message associated with the last request.
char*httpGetExt(HttpConn *conn)
 Get a URI extension.
cchar*httpGetFilePassword(HttpAuth *auth, cchar *realm, cchar *user)
 Get the password for a user from a file-based authentication database.
HttpAclhttpGetGroupAcl(HttpAuth *auth, char *group)
 Get the group ACL.
cchar*httpGetHeader(HttpConn *conn, cchar *key)
 Get an rx http header.
MprHash*httpGetHeaderHash(HttpConn *conn)
 Get the hash table of rx Http headers.
char*httpGetHeaders(HttpConn *conn)
 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(HttpConn *conn, cchar *var, int defaultValue)
 Get a form variable as an integer.
inthttpGetKeepAliveCount(HttpConn *conn)
 Get the count of Keep-Alive requests that will be used for this connection object.
HttpLang*httpGetLanguage(HttpConn *conn, MprHash *spoken, cchar *defaultLang)
 Get the language to use for the request.
cchar*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.
ssizehttpGetPacketLength(HttpPacket *packet)
 Get the length of the packet data contents.
cchar*httpGetParam(HttpConn *conn, cchar *var, cchar *defaultValue)
 Get a request param.
MprHash*httpGetParams(HttpConn *conn)
 Get the request params table.
char*httpGetParamsString(HttpConn *conn)
 Get the request params table as a string.
char*httpGetPathExt(cchar *path)
 Get a path extension.
cchar*httpGetQueryString(HttpConn *conn)
 Get the request query string.
void*httpGetQueueData(HttpConn *conn)
 Get the queue data for the connection.
ssizehttpGetQueueRoom(HttpQueue *q)
 Get the room in the 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*httpGetRouteDir(HttpRoute *route)
 Get the route directory.
cchar*httpGetRouteMethods(HttpRoute *route)
 Get the route method list.
cvoid*httpGetStageData(struct HttpConn *conn, cchar *key)
 Get stage data.
inthttpGetStatus(HttpConn *conn)
 Get the response status.
char*httpGetStatusMessage(HttpConn *conn)
 Get the Http response status message.
HttpLimits*httpGraduateLimits(HttpRoute *route)
 Graduate the limits from the parent route.
voidhttpHandleOptionsTrace(struct HttpConn *conn)
 Handle a Http Trace or Options method request.
boolhttpHasNamedVirtualHosts(HttpEndpoint *endpoint)
 Test if an endpoint has named virtual hosts.
voidhttpInitLimits(HttpLimits *limits, bool serverSide)
 Initialize a limits object with default values.
inthttpIsChunked(HttpConn *conn)
 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 HttpConn *conn)
 Test if the connection has received all incoming content.
inthttpIsFinalized(HttpConn *conn)
 Test if request has been finalized.
boolhttpIsGroupEnabled(HttpAuth *auth, cchar *group)
 Test if an authentication group is enabled.
boolhttpIsPacketTooBig(struct HttpQueue *q, HttpPacket *packet)
 Test if a packet is too big.
boolhttpIsQueueEmpty(HttpQueue *q)
 Determine if the queue is empty.
boolhttpIsUserEnabled(HttpAuth *auth, cchar *realm, cchar *user)
 Test if a user is enabled.
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 the packets together.
HttpUri*httpJoinUri(HttpUri *base, int argc, HttpUri **others)
 Join URIs.
HttpUri*httpJoinUriPath(HttpUri *result, HttpUri *base, HttpUri *other)
 Join a URI path.
char*httpLink(HttpConn *conn, cchar *target, MprHash *options)
 Create a URI link.
inthttpLoadSsl(Http *http)
 Load SSL.
voidhttpLogRoutes(HttpHost *host, bool full)
 Show the current route table to the error log.
struct HttpEndpoint*httpLookupEndpoint(Http *http, cchar *ip, int port)
 Lookup a listening endpoint.
struct HttpHost*httpLookupHost(Http *http, 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.
HttpRoute*httpLookupRoute(HttpHost *host, cchar *name)
 Lookup a route by name.
cchar*httpLookupRouteErrorDocument(HttpRoute *route, int status)
 Lookup an error document by HTTP status code.
struct HttpStage*httpLookupStage(Http *http, cchar *name)
 Lookup a stage by name.
void*httpLookupStageData(Http *http, cchar *name)
 Lookup stage data.
cchar*httpLookupStatus(Http *http, int status)
 Lookup a Http status code.
char*httpMakePath(HttpRoute *route, cchar *path)
 Make a filename path.
HttpUri*httpMakeUriLocal(HttpUri *uri)
 Make a URI local.
voidhttpMapFile(HttpConn *conn, HttpRoute *route)
 Map the request URI and route target to a filename.
voidhttpMatchHost(HttpConn *conn)
 Match the HttpHost object that should serve this request.
boolhttpMatchParam(HttpConn *conn, cchar *var, cchar *expected)
 Match a form variable with an expected value.
inthttpMatchRoute(HttpConn *conn, HttpRoute *route)
 Match a route against the current request.
voidhttpMemoryError(HttpConn *conn)
 Signal a memory allocation error.
boolhttpNeedRetry(HttpConn *conn, char **url)
 Determine if the transmission needs a transparent retry to implement authentication or redirection.
voidhttpNormalizeUri(HttpUri *uri)
 Normalize a URI.
char*httpNormalizeUriPath(cchar *uri)
 Normalize a URI.
voidhttpOmitBody(HttpConn *conn)
 Tell the tx to omit sending any body.
inthttpOpenQueue(HttpQueue *q, ssize chunkSize)
 Open the queue.
HttpAclhttpParseAcl(HttpAuth *auth, cchar *acl)
 Parse an access control list.
voidhttpPrepClientConn(HttpConn *conn, bool keepHeaders)
 Prepare a client connection for a new request.
voidhttpPrepServerConn(HttpConn *conn)
 Prepare a connection for a new request.
voidhttpProcessPipeline(HttpConn *conn)
 Run the process pipeline stage.
voidhttpPutBackPacket(struct HttpQueue *q, HttpPacket *packet)
 Put a packet back onto a queue.
voidhttpPutForService(struct HttpQueue *q, HttpPacket *packet, bool serviceQ)
 Put a packet onto the service queue.
voidhttpPutPacket(struct HttpQueue *q, HttpPacket *packet)
 Put a packet onto a queue.
voidhttpPutPacketToNext(struct HttpQueue *q, HttpPacket *packet)
 Put a packet onto the next queue.
ssizehttpRead(HttpConn *conn, char *buffer, ssize size)
 Read rx body data.
inthttpReadGroupFile(HttpAuth *auth, char *path)
 Read an authentication group file.
char*httpReadString(HttpConn *conn)
 Read response data as a string.
inthttpReadUserFile(HttpAuth *auth, char *path)
 Remove an authentication user file.
voidhttpRedirect(HttpConn *conn, int status, cchar *uri)
 Redirect the client.
voidhttpRemoveAllUploadedFiles(HttpConn *conn)
 Remove all uploaded files.
inthttpRemoveGroup(HttpAuth *auth, cchar *group)
 Remove a group.
inthttpRemoveHeader(HttpConn *conn, cchar *key)
 Remove a header from the transmission.
voidhttpRemoveOption(MprHash *options, cchar *field)
 Remove an option.
voidhttpRemoveQueue(HttpQueue *q)
 Remove a queue.
voidhttpRemoveUploadFile(HttpConn *conn, cchar *id)
 Remove an uploaded file.
inthttpRemoveUser(HttpAuth *auth, cchar *realm, cchar *user)
 Remove a user.
inthttpRemoveUserFromGroup(HttpGroup *gp, cchar *user)
 Remove user from a group.
inthttpRemoveUsersFromGroup(HttpAuth *auth, cchar *group, cchar *users)
 Remove users from a group.
voidhttpResetCredentials(HttpConn *conn)
 Reset the current security credentials.
voidhttpResetRoutePipeline(HttpRoute *route)
 Reset the route pipeline.
voidhttpResetRoutes(HttpHost *host)
 Reset the list of routes for the host.
inthttpResizePacket(struct HttpQueue *q, HttpPacket *packet, ssize size)
 Resize a packet.
HttpUri*httpResolveUri(HttpUri *base, int argc, HttpUri **others, bool local)
 Resolve URIs relative to a base.
voidhttpRouteRequest(HttpConn *conn)
 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.
voidhttpSendEndPacket(HttpQueue *q)
 Send an end packet.
voidhttpSendPackets(HttpQueue *q)
 Send all queued packets.
voidhttpServiceQueue(HttpQueue *q)
 Service a queue.
boolhttpServiceQueues(HttpConn *conn)
 Service pipeline queues to flow data.
voidhttpSetAsync(HttpConn *conn, int enable)
 Set the async mode value for the connection.
voidhttpSetAuthAllow(HttpAuth *auth, cchar *allow)
 Allow access by a client.
voidhttpSetAuthAnyValidUser(HttpAuth *auth)
 Allow access by any valid user.
voidhttpSetAuthDeny(HttpAuth *auth, cchar *deny)
 Deny access by a client.
voidhttpSetAuthOrder(HttpAuth *auth, int order)
 Set the auth allow/deny order.
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.
voidhttpSetAuthRequiredGroups(HttpAuth *auth, cchar *groups)
 Define the set of required groups for basic or digest authentication.
voidhttpSetAuthRequiredUsers(HttpAuth *auth, cchar *users)
 Define the set of required users for basic or digest authentication.
voidhttpSetAuthUser(HttpConn *conn, cchar *user)
 Set the required user for basic or digest authentication.
voidhttpSetChunkSize(HttpConn *conn, ssize size)
 Set the chunk size for transfer chunked encoding.
voidhttpSetConnContext(HttpConn *conn, void *context)
 Set the connection context object.
voidhttpSetConnHost(HttpConn *conn, void *host)
 Set the connection host object.
voidhttpSetConnNotifier(HttpConn *conn, HttpNotifier fn)
 Define a notifier callback for this connection.
voidhttpSetContentLength(HttpConn *conn, MprOff length)
 Define a content length header in the transmission.
voidhttpSetContentType(HttpConn *conn, cchar *mimeType)
 Set the transmission (response) content mime type.
voidhttpSetContext(Http *http, void *context)
 Set the http context object.
voidhttpSetCookie(HttpConn *conn, cchar *name, cchar *value, cchar *path, cchar *domain, MprTime lifespan, int flags)
 Set a transmission cookie.
voidhttpSetCredentials(HttpConn *conn, cchar *user, cchar *password)
 Set the Http credentials.
voidhttpSetDefaultClientHost(Http *http, cchar *host)
 Define a default client host.
voidhttpSetDefaultClientPort(Http *http, int port)
 Define a default client port.
voidhttpSetEndpointAddress(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.
voidhttpSetEntityLength(HttpConn *conn, MprOff len)
 Define the length of the transmission content.
voidhttpSetForkCallback(struct Http *http, MprForkCallback proc, void *arg)
 Set the fork callback.
inthttpSetGroupAcl(HttpAuth *auth, cchar *group, HttpAcl acl)
 Set the group access control list.
voidhttpSetHasNamedVirtualHosts(HttpEndpoint *endpoint, bool on)
 Control whether the endpoint has named virtual hosts.
voidhttpSetHeader(HttpConn *conn, cchar *key, cchar *fmt, ...)
 Set a transmission header.
voidhttpSetHeaderString(HttpConn *conn, cchar *key, cchar *value)
 Set a simple key/value transmission header.
voidhttpSetHeadersCallback(struct HttpConn *conn, HttpHeadersCallback fn, void *arg)
 Define a headers callback.
voidhttpSetHostDefaultRoute(HttpHost *host, HttpRoute *route)
 Set the default route for a host.
voidhttpSetHostHome(HttpHost *host, cchar *dir)
 Set the home directory for a host.
voidhttpSetHostIpAddr(HttpHost *host, cchar *ip, int port)
 Set the host internet address.
voidhttpSetHostName(HttpHost *host, cchar *name)
 Set the host name.
voidhttpSetHostProtocol(HttpHost *host, cchar *protocol)
 Set the host HTTP protocol version.
voidhttpSetIOCallback(struct HttpConn *conn, HttpIOCallback fn)
 Define an I/O callback for connections.
voidhttpSetIntParam(HttpConn *conn, cchar *var, int value)
 Set an integer request param value.
voidhttpSetKeepAliveCount(HttpConn *conn, int count)
 Control Http Keep-Alive for the connection.
voidhttpSetMethod(HttpConn *conn, cchar *method)
 Set a new HTTP method for processing.
voidhttpSetOption(MprHash *options, cchar *field, cchar *value)
 Set an option.
voidhttpSetParam(HttpConn *conn, cchar *var, cchar *value)
 Set a request param value.
voidhttpSetPipelineHandler(HttpConn *conn, HttpStage *handler)
 Set the handler to process a client request.
voidhttpSetProtocol(HttpConn *conn, cchar *protocol)
 Set the Http protocol variant for this connection.
voidhttpSetProxy(Http *http, cchar *host, int port)
 Define a Http proxy host to use for all client connect requests.
voidhttpSetRequiredAcl(HttpAuth *auth, HttpAcl acl)
 Set the required access control list for the authentication object.
voidhttpSetResponded(HttpConn *conn)
 Set the responded flag for the request.
voidhttpSetRetries(HttpConn *conn, int retries)
 Set the Http retry count.
voidhttpSetRouteAuth(HttpRoute *route, HttpAuth *auth)
 Set the route authentication.
voidhttpSetRouteAutoDelete(HttpRoute *route, bool on)
 Control file upload auto delete.
voidhttpSetRouteCompression(HttpRoute *route, int flags)
 Contol content compression for the route.
inthttpSetRouteConnector(HttpRoute *route, cchar *name)
 Set the connector to use for a route.
voidhttpSetRouteData(HttpRoute *route, cchar *key, void *data)
 Set route data.
voidhttpSetRouteDefaultLanguage(HttpRoute *route, cchar *language)
 Set the default language for the route.
voidhttpSetRouteDir(HttpRoute *route, cchar *dir)
 Set the route directory.
voidhttpSetRouteFlags(HttpRoute *route, int flags)
 Update the route flags.
inthttpSetRouteHandler(HttpRoute *route, cchar *name)
 Set the handler to use for a route.
voidhttpSetRouteLog(HttpRoute *route, cchar *path, ssize size, int backup, cchar *format, int flags)
 Configure the route access log.
voidhttpSetRouteMethods(HttpRoute *route, cchar *methods)
 Define the methods for the route.
voidhttpSetRouteName(HttpRoute *route, cchar *name)
 Set the route name.
voidhttpSetRoutePathVar(HttpRoute *route, cchar *token, cchar *value)
 Define a path token variable.
voidhttpSetRoutePattern(HttpRoute *route, cchar *pattern, int flags)
 Set the route pattern.
voidhttpSetRoutePrefix(HttpRoute *route, cchar *prefix)
 Set the route prefix.
voidhttpSetRouteScript(HttpRoute *route, cchar *script, cchar *scriptPath)
 Set the script to service the route.
voidhttpSetRouteSource(HttpRoute *route, cchar *source)
 Set the source code module for the route.
inthttpSetRouteTarget(HttpRoute *route, cchar *name, cchar *details)
 Set a route target.
voidhttpSetRouteTemplate(HttpRoute *route, cchar *tplate)
 Set the route template.
voidhttpSetRouteTraceFilter(HttpRoute *route, int dir, int levels[HTTP_TRACE_MAX_ITEM], ssize len, cchar *include, cchar *exclude)
 Set the route trace filter.
voidhttpSetRouteWorkers(HttpRoute *route, int workers)
 Define the maximum number of workers for a route.
voidhttpSetSendConnector(HttpConn *conn, cchar *path)
 Set the "Send" connector to process the request.
voidhttpSetSoftware(Http *http, cchar *description)
 Set the software description.
voidhttpSetStageData(struct HttpConn *conn, cchar *key, cvoid *data)
 Set stage data.
voidhttpSetState(HttpConn *conn, int state)
 Set the connection state and invoke notifiers.
voidhttpSetStatus(HttpConn *conn, int status)
 Set a Http response status.
voidhttpSetTimeout(HttpConn *conn, int requestTimeout, int inactivityTimeout)
 Set the Http inactivity timeout.
inthttpSetUri(HttpConn *conn, cchar *uri, cchar *query)
 Set a new URI for processing.
voidhttpSetWriteBlocked(HttpConn *conn)
 Indicate that the transmission socket is blocked.
inthttpShouldTrace(HttpConn *conn, int dir, int item, cchar *ext)
 Test if the item should be traced.
HttpPacket*httpSplitPacket(HttpPacket *packet, ssize offset)
 Split a data packet.
inthttpStartEndpoint(HttpEndpoint *endpoint)
 Start listening for client connections.
voidhttpStartPipeline(HttpConn *conn)
 Start the pipeline.
voidhttpStopEndpoint(HttpEndpoint *endpoint)
 Stop the server listening for client connections.
char*httpTemplate(HttpConn *conn, cchar *tplate, MprHash *options)
 Expand a template string using given options.
inthttpTestParam(HttpConn *conn, 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.
voidhttpTrimExtraPath(HttpConn *conn)
 Trim extra path from the URI.
ssizehttpUpdateCache(HttpConn *conn, cchar *uri, cchar *data, MprTime lifespan)
 Update the cached content for a URI.
voidhttpUpdateUserAcls(HttpAuth *auth)
 Update the user access control list.
char*httpUriToString(HttpUri *uri, int complete)
 Convert a Uri to a string.
boolhttpValidateFileCredentials(HttpAuth *auth, cchar *realm, cchar *user, cchar *password, cchar *requiredPass, char **msg)
 Validate credentials using a file-based authentication database.
boolhttpValidateLimits(HttpEndpoint *endpoint, int event, HttpConn *conn)
 Validate the request against defined resource limits.
boolhttpVerifyQueue(HttpQueue *q)
 Verify a queue.
inthttpWait(HttpConn *conn, int state, MprTime timeout)
 Wait for the connection to achieve the requested state Used for blocking client requests.
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.
voidhttpWritable(HttpConn *conn)
 Inform notifiers that the connection is now writable.
ssizehttpWrite(HttpQueue *q, cchar *fmt, ...)
 Write a formatted string.
ssizehttpWriteBlock(HttpQueue *q, cchar *buf, ssize size)
 Write a block of data to the queue.
ssizehttpWriteCached(HttpConn *conn)
 Write the cached content for a URI to the client.
inthttpWriteGroupFile(HttpAuth *auth, char *path)
 Write out the group authentication database.
voidhttpWriteHeaders(HttpConn *conn, HttpPacket *packet)
 Write the transmission headers.
voidhttpWriteRouteLog(HttpRoute *route, cchar *buf, ssize len)
 Write data to the route access log.
ssizehttpWriteString(HttpQueue *q, cchar *s)
 Write a string of data to the queue.
ssizehttpWriteUploadData(HttpConn *conn, MprList *formData, MprList *fileData)
 Write Http upload body data.
inthttpWriteUserFile(HttpAuth *auth, char *path)
 Write out the user authentication database.

Typedefs

HttpAclAuthentication Access control mask.
HttpEnvCallbackSet environment vars callback.
HttpFillProcCallback procedure to fill a packet with data.
HttpGetPasswordLookup password callback.
HttpGroupGroup Authorization.
HttpHeadersCallbackCallback to fill headers.
HttpIOCallbackI/O callback for connections.
HttpLangLanguage definition record for routes.
HttpListenCallbackListen callback.
HttpNotifierConnection Http state change notification callback.
HttpRedirectCallbackDefine an callback for IO events on this connection.
HttpRouteOpRoute operation record.
HttpRouteProcGeneral route procedure.
HttpUserUser Authorization File-based authorization backend.
HttpValidateCredValidate user credentials callback.

Defines

#defineHTTP_ADDED_FORM_PARAMS   0x1000
 Form body data added to params.
#defineHTTP_ADDED_QUERY_PARAMS   0x800
 Query added to params.
#defineHTTP_ALLOW_DENY   1
 Run allow checks before deny checks.
#defineHTTP_AUTH_BASIC   1
 Basic HTTP authentication (clear text).
#defineHTTP_AUTH_DIGEST   2
 Digest authentication.
#defineHTTP_AUTH_METHOD_FILE   1
 File-based authentication.
#defineHTTP_AUTH_METHOD_PAM   2
 Plugable authentication module scheme (Unix).
#defineHTTP_AUTH_REQUIRED   0x1
 Route requires authentication.
#defineHTTP_AUTH_UNKNOWN   0
 Authentication method is unknown.
#defineHTTP_BUFSIZE   (8 * 1024)
 Default I/O buffer size.
#defineHTTP_CACHE_ALL   0x10
 Cache the same pathInfo together regardless of the request params.
#defineHTTP_CACHE_CLIENT   0x1
 Cache on the client side.
#defineHTTP_CACHE_LIFESPAN   (86400 * 1000)
 Default cache lifespan to 1 day.
#defineHTTP_CACHE_MANUAL   0x4
 Cache manually.
#defineHTTP_CACHE_ONLY   0x20
 Cache exactly the specified URI with params.
#defineHTTP_CACHE_RESET   0x8
 Don't inherit cache config from outer routes.
#defineHTTP_CACHE_SERVER   0x2
 Cache on the server side.
#defineHTTP_CACHE_UNIQUE   0x40
 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   0x400
 Content is chunk encoded.
#defineHTTP_CLIENTS_HASH   (131)
 Hash table for client IP addresses.
#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_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_COMMS_ERROR   550
 The server had a communicationss 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_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_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_COOKIE_HTTP   0x2
 Flag for httpSetCookie for http cookies (http only).
#defineHTTP_COOKIE_SECURE   0x1
 Flag for httpSetCookie for secure cookies (https only).
#defineHTTP_CREATE_ENV   0x100
 Must create env for this request.
#defineHTTP_DEFAULT_MAX_THREADS   10
 Default number of threads.
#defineHTTP_DELAY_SERVICE   0
 Delay servicing the queue.
#defineHTTP_DELETE   0x1
 DELETE method.
#defineHTTP_DENY_ALLOW   2
 Run deny checks before allow checks.
#defineHTTP_EVENT_CLOSE   -1
 Connection being closed.
#defineHTTP_EVENT_IO   0
 I/O event on connection.
#defineHTTP_GET   0x2
 GET method.
#defineHTTP_HEAD   0x4
 HEAD method.
#defineHTTP_HOST_NAMED_VHOST   0x2
 Host flag for a named virtual host.
#defineHTTP_HOST_NO_TRACE   0x10
 Host flag to disable the of TRACE HTTP method.
#defineHTTP_HOST_VHOST   0x1
 Host flag to signify host is a virtual host.
#defineHTTP_IF_MODIFIED   0x200
 If-[un]modified-since supplied.
#defineHTTP_INACTIVITY_TIMEOUT   (60 * 1000)
 Keep connection alive timeout.
#defineHTTP_LANG_AFTER   0x2
 Insert suffix after extension.
#defineHTTP_LANG_BEFORE   0x1
 Insert suffix before extension.
#defineHTTP_MAX_CACHE_ITEM   (256 * 1024)
 Maximum cachable item size.
#defineHTTP_MAX_CHUNK   (8 * 1024)
 Maximum chunk size for transfer chunk encoding.
#defineHTTP_MAX_CLIENTS   10
 Maximum concurrent client endpoints.
#defineHTTP_MAX_HEADERS   4096
 Maximum size of the headers.
#defineHTTP_MAX_IOVEC   16
 Number of fragments in a single socket write.
#defineHTTP_MAX_KEEP_ALIVE   100
 Maximum requests per connection.
#defineHTTP_MAX_NUM_HEADERS   20
 Maximum number of header lines.
#defineHTTP_MAX_PASS   64
 Size of password.
#defineHTTP_MAX_QUEUE   2
 Number of queue types.
#defineHTTP_MAX_RECEIVE_BODY   (128 * 1024 * 1024)
 Maximum incoming body size.
#defineHTTP_MAX_RECEIVE_FORM   (1024 * 1024)
 Maximum incoming form size.
#defineHTTP_MAX_REQUESTS   20
 Maximum concurrent requests.
#defineHTTP_MAX_REWRITE   20
 Maximum URI rewrites.
#defineHTTP_MAX_ROUTE_MATCHES   32
 Maximum number of submatches in routes.
#defineHTTP_MAX_SECRET   32
 Size of secret data for auth.
#defineHTTP_MAX_SESSIONS   100
 Maximum concurrent sessions.
#defineHTTP_MAX_STAGE_BUFFER   (32 * 1024)
 Maximum buffer for any stage.
#defineHTTP_MAX_TX_BODY   (INT_MAX)
 Maximum buffer for response data.
#defineHTTP_METHOD_MASK   0xFFF
 Method mask.
#defineHTTP_NAME   "Embedthis-http/" BLD_VERSION
 Default library name used in Http headers.
#defineHTTP_NAMED_VHOST   0x1
 Using named virtual hosting.
#defineHTTP_NOTIFY_CLOSED   0x4
 The request is now closed.
#defineHTTP_NOTIFY_ERROR   0x8
 The request has an error.
#defineHTTP_NOTIFY_READABLE   0x1
 Notification flags.
#defineHTTP_NOTIFY_WRITABLE   0x2
 The request is now writable (post / put data).
#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_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_DISABLED   0x2
 Queue's service routine is disabled.
#defineHTTP_QUEUE_EOF   0x20
 Queue at end of data.
#defineHTTP_QUEUE_FULL   0x4
 Queue is full.
#defineHTTP_QUEUE_OPEN   0x1
 Queue's open routine has been called.
#defineHTTP_QUEUE_RESERVICE   0x80
 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
 Queue started.
#defineHTTP_QUEUE_TX   0
 Send (transmit to client) queue.
#defineHTTP_RANGE_BUFSIZE   128
 Size of a range boundary.
#defineHTTP_RETRIES   3
 Default number of retries for client requests.
#defineHTTP_ROUTE_FREE   0x2
 Free Route.mdata back to malloc when route is freed.
#defineHTTP_ROUTE_GZIP   0x2000
 Support gzipped content.
#defineHTTP_ROUTE_NOT   0x1
 Negate the route pattern test result.
#defineHTTP_ROUTE_OK   0
 The route matches the request.
#defineHTTP_ROUTE_PUT_DELETE   0x1000
 Support PUT|DELETE.
#defineHTTP_ROUTE_RAW   0x4
 Don't html encode the write data.
#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_SESSION_TIMEOUT   (3600 * 1000)
 One hour.
#defineHTTP_STAGE_ALL   HTTP_METHOD_MASK
 Mask for every possible method including custom methods.
#defineHTTP_STAGE_AUTO_DIR   0x10000
 Want auto directory redirection.
#defineHTTP_STAGE_CONNECTOR   0x1000
 Stage is a connector.
#defineHTTP_STAGE_DELETE   HTTP_DELETE
 Support DELETE requests.
#defineHTTP_STAGE_FILTER   0x4000
 Stage is a filter.
#defineHTTP_STAGE_GET   HTTP_GET
 Support GET requests.
#defineHTTP_STAGE_HANDLER   0x2000
 Stage is a handler.
#defineHTTP_STAGE_HEAD   HTTP_HEAD
 Support HEAD requests.
#defineHTTP_STAGE_METHODS   (HTTP_DELETE|HTTP_GET|HTTP_HEAD|HTTP_POST|HTTP_PUT)
 Support default methods.
#defineHTTP_STAGE_MODULE   0x8000
 Stage is a filter.
#defineHTTP_STAGE_OPTIONS   HTTP_OPTIONS
 Support OPTIONS requests.
#defineHTTP_STAGE_POST   HTTP_POST
 Support POST requests.
#defineHTTP_STAGE_PUT   HTTP_PUT
 Support PUT requests.
#defineHTTP_STAGE_RX   0x40000
 Stage to be used in the Rx direction.
#defineHTTP_STAGE_TRACE   HTTP_TRACE
 Support TRACE requests.
#defineHTTP_STAGE_TX   0x80000
 Stage to be used in the Tx direction.
#defineHTTP_STAGE_UNKNOWN   HTTP_UNKNOWN
 Support TRACE requests.
#defineHTTP_STAGE_UNLOADED   0x20000
 Stage module library has been unloaded.
#defineHTTP_STATE_BEGIN   1
 Ready for a new request.
#defineHTTP_STATE_COMPLETE   7
 Request complete.
#defineHTTP_STATE_CONNECTED   2
 Connection received or made.
#defineHTTP_STATE_CONTENT   5
 Reading posted content.
#defineHTTP_STATE_FIRST   3
 First request line has been parsed.
#defineHTTP_STATE_PARSED   4
 Headers have been parsed, handler can start.
#defineHTTP_STATE_RUNNING   6
 Handler running.
#defineHTTP_TIMER_PERIOD   1000
 Timer checks ever 1 second.
#defineHTTP_TRACE   0x40
 TRACE method.
#defineHTTP_TRACE_BODY   3
 Body content.
#defineHTTP_TRACE_CONN   0
 New connections.
#defineHTTP_TRACE_FIRST   1
 First line of header only.
#defineHTTP_TRACE_HEADER   2
 Header.
#defineHTTP_TRACE_LIMITS   4
 Instrument http pipeline.
#defineHTTP_TRACE_MAX_DIR   2
 Trace transmission.
#defineHTTP_TRACE_RX   0
 Trace reception.
#defineHTTP_TRACE_TIME   5
 Instrument http pipeline.
#defineHTTP_TRACE_TX   1
 Trace transmission.
#defineHTTP_TX_HEADERS_CREATED   0x2
 Response headers have been created.
#defineHTTP_TX_NO_BODY   0x1
 No transmission body, only sent headers.
#defineHTTP_TX_SENDFILE   0x4
 Relay output via Send connector.
#defineHTTP_UNKNOWN   0x800
 Unknown method.
#defineHTTP_VALIDATE_CLOSE_CONN   2
 Close a connection.
#defineHTTP_VALIDATE_CLOSE_REQUEST   4
 Close a request.
#defineHTTP_VALIDATE_OPEN_CONN   1
 Open a new connection.
#defineHTTP_VALIDATE_OPEN_REQUEST   3
 Open a new request.

Http

Http

Http service object.

Description:
The Http service is managed by a single service object.
API Stability:
Evolving.
See Also:
HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
Fields:
MprTimebooted Time the server started.
struct HttpStage *cacheFilter Cache filter.
struct HttpStage *cacheHandler Cache filter.
struct HttpStage *cgiHandler CGI listing handler.
struct HttpStage *chunkFilter Chunked transfer encoding filter.
struct HttpLimits *clientLimits Client resource limits.
struct HttpRoute *clientRoute Default route for clients.
intconnCount Count of connections for Conn.seqno.
MprList *connections Currently open connection requests.
void *context Embedding context.
char *currentDate Date string for HTTP response headers.
char *defaultClientHost Default ip address.
intdefaultClientPort Default port.
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.
char *expiresDate Convenient expiry date (1 day in advance).
struct HttpStage *fileHandler Static file handler.
MprForkCallbackforkCallback Callback in child after fork().
HttpGetPasswordgetPassword Lookup password callback.
MprList *hosts List of host objects.
HttpListenCallbacklistenCallback Invoked when creating listeners.
struct HttpStage *netConnector Default network connector.
MprTimenow When was the currentDate last computed.
struct HttpStage *passHandler Pass through handler.
struct HttpStage *phpHandler PHP through handler.
char *protocol HTTP/1.0 or HTTP/1.1.
char *proxyHost Proxy ip address.
intproxyPort Proxy port.
struct HttpStage *rangeFilter Ranged requests filter.
HttpRedirectCallbackredirectCallback Redirect callback.
MprHash *routeConditions Http route condition functions.
MprHash *routeTargets Http route target functions.
MprHash *routeUpdates Http route update functions.
char *secret Random bytes for authentication.
struct HttpStage *sendConnector Optimized sendfile connector.
struct HttpLimits *serverLimits Server resource limits.
char *software Software name and version.
intsslLoaded True when the SSL provider has been loaded.
MprHash *stages Possible stages in connection pipelines.
MprHash *statusCodes Http status codes.
MprEvent *timer Admin service timer.
struct HttpStage *uploadFilter Upload filter.
HttpValidateCredvalidateCred Validate user credentials callback.
Http * httpCreate ()

Create a Http service object.

Description:
Create a http service object. One http service object should be created per application.
Returns:
The http service object.
See Also:
Http, HttpConn, HttpEndpoint, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
int httpCreateSecret (Http *http)

Create the Http secret data for crypto.

Description:
Create http secret data that is used to seed SSL-based communications.
Parameters:
httpHttp service object.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
void httpDestroy (Http *http)
void * httpGetContext (Http *http)

Get the http context object.

Parameters:
httpHttp service object.
Returns:
The http context object defined via httpSetContext.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
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.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
int httpLoadSsl (Http *http)

Load SSL.

Description:
This loads the configured SSL provider. SSL providers are configured when the product is built from source.
Parameters:
httpHttp object created via httpCreate
Returns:
"Zero" if SSL can be successfully loaded. Otherwise return a negative MPR error code.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
struct HttpHost * HttpHost* httpLookupHost (Http *http, cchar *name)

Lookup a host by name.

Parameters:
httpHttp object created via httpCreate
nameThe name of the host to find.
Returns:
The corresponding host object.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
cchar * httpLookupStatus (Http *http, int status)

Lookup a Http status code.

Description:
Lookup the code and return the corresponding text message briefly expaining the status.
Parameters:
httpHttp object created via httpCreate
statusHttp status code.
Returns:
Text message corresponding to the status code.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback, httpSetProxy
void httpSetProxy (Http *http, 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:
httpHttp object created via httpCreate
hostProxy host name or IP address.
portProxy host port number.
See Also:
Http, HttpConn, HttpEndpoint, httpCreate, httpCreateSecret, httpDestroy, httpGetContext, httpGetDateString, httpLoadSsl, httpLookupStatus, httpSetDefaultClientHost, httpSetDefaultClientPort, httpSetForkCallback

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.
API Stability:
Evolving.
See Also:
HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddGroup, httpAddUser, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
Fields:
MprHash *allow Clients to allow.
boolanyValidUser If any valid user will do.
intbackend Authorization method (PAM | FILE).
MprHash *deny Clients to deny.
intflags Authorization flags.
char *groupFile Group authorization file.
MprHash *groups Hash of group file.
intorder Order deny/allow, allow/deny.
char *qop Digest Qop.
HttpAclrequiredAcl ACL for access.
char *requiredGroups Authorization group for access.
char *requiredRealm Realm to use for access.
char *requiredUsers User name for access.
inttype Kind of authorization.
char *userFile User name authorization file.
MprHash *users Hash of user file.
int httpAddGroup (HttpAuth *auth, cchar *group, HttpAcl acl, bool enabled)

Add a group.

Description:
This creates the group and adds it to the authentication database.
Parameters:
authAuth object allocated by httpCreateAuth. Authenticated routes typically store the reference to an auth object.
groupGroup name to add.
aclGroup access control list mask.
enabledSet to true to enable the group.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddUser, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
int httpAddUser (HttpAuth *auth, cchar *realm, cchar *user, cchar *password, bool enabled)

Add a user.

Description:
This creates the user and adds the user to the authentication database.
Parameters:
authAuth object allocated by httpCreateAuth. Authenticated routes typically store the reference to an auth object.
realmAuthentication realm.
userUser name to add.
passwordUser password. The password should not be encrypted. The backend will encrypt as required.
enabledSet to true to enable the user.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddGroup, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
int httpAddUsersToGroup (HttpAuth *auth, cchar *group, cchar *users)

Add users to a group.

Description:
This creates the users and adds them to the authentication database.
Parameters:
authAuth object allocated by httpCreateAuth. Authenticated routes typically store the reference to an auth object.
groupGroup name to add.
usersSpace or comma separated list of user names.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddGroup, httpAddUser, httpAddUserToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
int httpAddUserToGroup (HttpAuth *auth, HttpGroup *gp, cchar *user)
HttpAuth * httpCreateAuth ()
HttpGroup * httpCreateGroup (HttpAuth *auth, cchar *name, HttpAcl acl, bool enabled)
HttpUser * httpCreateUser (HttpAuth *auth, cchar *name, cchar *password, cchar *realm, bool enabled)

Create a new user.

Description:
The user is not added to the authentication database.
Parameters:
authAuth object allocated by httpCreateAuth. Authenticated routes typically store the reference to an auth object.
nameUser name.
passwordUser password. The password should not be encrypted. The backend will encrypt as required.
realmAuthentication realm for this user.
enabledSet to true to enable the user.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddGroup, httpAddUser, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
int httpDisableGroup (HttpAuth *auth, cchar *group)
int httpDisableUser (HttpAuth *auth, cchar *realm, cchar *user)
int httpEnableGroup (HttpAuth *auth, cchar *group)
int httpEnableUser (HttpAuth *auth, cchar *realm, cchar *user)
cchar * httpGetFilePassword (HttpAuth *auth, cchar *realm, cchar *user)
HttpAcl httpGetGroupAcl (HttpAuth *auth, char *group)
bool httpIsGroupEnabled (HttpAuth *auth, cchar *group)
bool httpIsUserEnabled (HttpAuth *auth, cchar *realm, cchar *user)
HttpAcl httpParseAcl (HttpAuth *auth, cchar *acl)
int httpReadGroupFile (HttpAuth *auth, char *path)
int httpReadUserFile (HttpAuth *auth, char *path)
int httpRemoveGroup (HttpAuth *auth, cchar *group)
int httpRemoveUser (HttpAuth *auth, cchar *realm, cchar *user)
int httpRemoveUserFromGroup (HttpGroup *gp, cchar *user)
int httpRemoveUsersFromGroup (HttpAuth *auth, cchar *group, cchar *users)
void httpSetAuthAllow (HttpAuth *auth, cchar *allow)
void httpSetAuthAnyValidUser (HttpAuth *auth)
void httpSetAuthDeny (HttpAuth *auth, cchar *deny)
void httpSetAuthOrder (HttpAuth *auth, int order)
void httpSetAuthQop (HttpAuth *auth, cchar *qop)
void httpSetAuthRealm (HttpAuth *auth, cchar *realm)
void httpSetAuthRequiredGroups (HttpAuth *auth, cchar *groups)
void httpSetAuthRequiredUsers (HttpAuth *auth, cchar *users)
void httpSetAuthUser (HttpConn *conn, cchar *user)
int httpSetGroupAcl (HttpAuth *auth, cchar *group, HttpAcl acl)
void httpSetRequiredAcl (HttpAuth *auth, HttpAcl acl)
void httpUpdateUserAcls (HttpAuth *auth)
bool httpValidateFileCredentials (HttpAuth *auth, cchar *realm, cchar *user, cchar *password, cchar *requiredPass, char **msg)

Validate credentials using a file-based authentication database.

Parameters:
authAuth object allocated by httpCreateAuth. Authenticated routes typically store the reference to an auth object.
realmAuthentication realm.
userUser name.
passwordUser password.
requiredPassRequired user password.
msgOutput parameter, error message.
Returns:
True if the user could be successfully validated.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, HttpValidateCred, httpAddGroup, httpAddUser, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpWriteGroupFile, httpWriteUserFile
int httpWriteGroupFile (HttpAuth *auth, char *path)
int httpWriteUserFile (HttpAuth *auth, char *path)

HttpCache

HttpCache

Cache Control.

API Stability:
Evolving.
See Also:
httpAddCache, httpUpdateCache
Fields:
MprTimeclientLifespan Lifespan for client cached content.
MprHash *extensions Extensions to cache.
intflags Cache control flags.
MprHash *methods Methods to cache.
MprTimeserverLifespan 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, MprTime clientLifespan, MprTime 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".
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 ESP_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 ESP_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_ALL, HTTP_CACHE_ONLY or HTTP_CACHE_UNIQUE to define the server-side caching mode. Only one of these three mode flags should be specified.

If the HTTP_CACHE_ALL flag is set, the request params (query, post data, and route parameters) will be ignored and all requests for a given URI path will cache to the same cache record.

Select HTTP_CACHE_UNIQUE to uniquely cache requests with different request parameters. The URIs specified in $uris should not contain any request parameters.

Select HTTP_CACHE_ONLY to cache only the exact URI with parameters specified in $uris. The parameters must be in sorted www-urlencoded format. For example: /example.esp?hobby=sailing&name=john.
Returns:
A count of the bytes actually written.
See Also:
HttpCache, httpUpdateCache
ssize httpUpdateCache (HttpConn *conn, cchar *uri, cchar *data, MprTime lifespan)

Update the cached content for a URI.

Parameters:
connHttpConn connection object.
uriThe request URI for which to update the cache. If using the HTTP_CACHE_ONLY flag when configuring the cached item, then the URI should contain the request parameters in sorted www-urlencoded format.
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. For example: "Content-Type: text/plain\n\nHello World\n".
lifespanLifespan in milliseconds for the cached content.
See Also:
HttpCache, httpAddCache
ssize httpWriteCached (HttpConn *conn)

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:
connHttpConn connection object.
See Also:
HttpCache, httpAddCache, httpUpdateCache

HttpConn

HttpConn

Http Connections.

Description:
The HttpConn object represents a TCP/IP connection to the client. A connection object is created for each socket connection initiated by the client. One HttpConn object may service many Http requests due to HTTP/1.1 keep-alive.
API Stability:
Evolving.
See Also:
HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnTimeout, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpGetKeepAliveCount, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetKeepAliveCount, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpShouldTrace, httpStartPipeline, httpWritable
Fields:
intadvancing In httpProcess (re-entrancy prevention).
intasync Connection is in async mode (non-blocking).
char *authCnonce Digest authentication cnonce value.
char *authDomain Authentication domain.
intauthNc Digest authentication nc value.
char *authNonce Nonce value used in digest authentication.
char *authOpaque Opaque value used to calculate digest session.
char *authPassword Password credentials for authorized client requests.
char *authQop Digest authentication qop value.
char *authRealm Authentication realm.
char *authType Basic or Digest.
char *authUser User name credentials for authorized client requests.
char *boundary File upload boundary.
intcanProceed State machine should continue to process the request.
intconnectorComplete Connector has finished sending the response.
HttpQueue *connectorq Connector write queue.
intconnError A connection error has occurred.
void *context Embedding context (EjsRequest).
struct HttpQueue *currentq Current queue being serviced (just for GC).
void *data Custom data for request.
MprDispatcher *dispatcher Event dispatcher.
void *ejs Embedding VM.
struct HttpEndpoint *endpoint Endpoint object (if set - indicates server-side).
interror A request error has occurred.
char *errorMsg Error message for the last request (if any).
intfinalized End of response has been signified (set at handler level).
intfollowRedirects Follow redirects for client requests.
void *grid Current request database grid for MVC apps.
HttpHeadersCallbackheadersCallback Callback to fill headers.
void *headersCallbackArg Arg to fillHeaders.
struct HttpHost *host Host object (if relevant).
Http *http Http service object.
inthttp10 Using legacy HTTP/1.0.
HttpPacket *input Header packet.
HttpIOCallbackioCallback I/O event callback.
char *ip Remote client IP address.
intkeepAliveCount Count of remaining Keep-Alive requests for this connection.
MprTimelastActivity Last activity on the connection.
HttpLimits *limits Service limits.
void *mark Reference for GC marking.
MprDispatcher *newDispatcher New dispatcher if using a worker thread.
HttpNotifiernotifier Connection Http state change notification callback.
MprDispatcher *oldDispatcher Original dispatcher if using a worker thread.
void *pool Pool of VMs.
intport Remote port.
char *protocol HTTP protocol.
HttpQueue *readq End of the read pipeline.
void *record Current request database record for MVC apps.
intrefinalize Finalize required once the Tx pipeline is created.
intresponded The request has started to respond. Some output has been initiated.
intretries Client request retries.
struct HttpRx *rx Rx object.
intsecure Using https.
intsentCredentials Sent authorization credentials.
intseqno Unique connection sequence number.
struct HttpQueue *serviceq List of queues that require service for request pipeline.
MprSocket *sock Underlying socket handle.
MprHash *stages Stages in pipeline.
MprTimestarted When the connection started.
intstate Connection state.
MprEvent *timeoutEvent Connection or request timeout event.
HttpTracetrace[2] Tracing for [rx|tx].
struct HttpTx *tx Tx object.
MprWaitHandler *waitHandler I/O wait handler.
intworker Use worker.
MprEvent *workerEvent Event for running connection via a worker thread.
intwriteBlocked Transmission writing is blocked.
HttpQueue *writeq Start of the write pipeline.
void httpCallEvent (HttpConn *conn, int mask)
void httpCloseConn (HttpConn *conn)
void httpConnectorComplete (HttpConn *conn)
void httpConnTimeout (HttpConn *conn)

Signal a connection timeout on a connection.

Description:
This call cancels a connections current request, disconnects the socket and issues an error to the error log. This call is normally invoked by the httpTimer which runs regularly to check for timed out requests. This call should not be made on another thread, but should be scheduled to run on the connection's dispatcher to avoid thread races.
Parameters:
connHttpConn connection object created via $httpCreateConn.
See Also:
HttpConn, HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpGetKeepAliveCount, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetKeepAliveCount, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpShouldTrace, httpStartPipeline, httpWritable
void httpConsumeLastRequest (HttpConn *conn)
HttpConn * httpCreateConn (Http *http, struct HttpEndpoint *endpoint, MprDispatcher *dispatcher)
void httpCreateRxPipeline (HttpConn *conn, struct HttpRoute *route)
void httpCreateTxPipeline (HttpConn *conn, struct HttpRoute *route)
void httpDestroyConn (HttpConn *conn)
void httpDestroyPipeline (HttpConn *conn)
void httpDiscardTransmitData (HttpConn *conn)
void httpDisconnect (HttpConn *conn)
void httpEnableConnEvents (HttpConn *conn)
void httpEnableUpload (HttpConn *conn)
void httpError (HttpConn *conn, int status, cchar *fmt, ...)
void httpEvent (struct HttpConn *conn, MprEvent *event)
int httpGetAsync (HttpConn *conn)
ssize httpGetChunkSize (HttpConn *conn)
void * httpGetConnContext (HttpConn *conn)
void * httpGetConnHost (HttpConn *conn)
cchar * httpGetError (HttpConn *conn)
char * httpGetExt (HttpConn *conn)
int httpGetKeepAliveCount (HttpConn *conn)

Get the count of Keep-Alive requests that will be used for this connection object.

Description:
Http Keep-Alive means that the TCP/IP connection is preserved accross multiple requests. This typically means much higher performance and better response. Http Keep-Alive is enabled by default for Http/1.1 (the default). Disable Keep-Alive when talking to old, broken HTTP servers.
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
The maximum count of Keep-Alive requests.
See Also:
HttpConn, HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnTimeout, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetKeepAliveCount, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpShouldTrace, httpStartPipeline, httpWritable
void httpMatchHost (HttpConn *conn)
void httpMemoryError (HttpConn *conn)
void httpPrepClientConn (HttpConn *conn, bool keepHeaders)
void httpPrepServerConn (HttpConn *conn)
void httpProcessPipeline (HttpConn *conn)
void httpResetCredentials (HttpConn *conn)
void httpRouteRequest (HttpConn *conn)
void httpSetAsync (HttpConn *conn, int enable)
void httpSetChunkSize (HttpConn *conn, ssize size)
void httpSetConnContext (HttpConn *conn, void *context)
void httpSetConnHost (HttpConn *conn, void *host)
void httpSetConnNotifier (HttpConn *conn, HttpNotifier fn)
void httpSetCredentials (HttpConn *conn, cchar *user, cchar *password)
void httpSetDefaultClientHost (Http *http, cchar *host)
void httpSetDefaultClientPort (Http *http, int port)
void httpSetEndpointNotifier (HttpEndpoint *endpoint, HttpNotifier fn)
void httpSetForkCallback (struct Http *http, MprForkCallback proc, void *arg)
void httpSetHeadersCallback (struct HttpConn *conn, HttpHeadersCallback fn, void *arg)
void httpSetIOCallback (struct HttpConn *conn, HttpIOCallback fn)
void httpSetKeepAliveCount (HttpConn *conn, int count)

Control Http Keep-Alive for the connection.

Description:
Http Keep-Alive means that the TCP/IP connection is preserved accross multiple requests. This typically means much higher performance and better response. Http Keep-Alive is enabled by default for Http/1.1 (the default). Disable Keep-Alive when talking to old, broken HTTP servers.
Parameters:
connHttpConn connection object created via $httpCreateConn.
countCount of Keep-Alive transactions to use before closing the connection. Set to zero to disable keep-alive.
See Also:
HttpConn, HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnTimeout, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpGetKeepAliveCount, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpShouldTrace, httpStartPipeline, httpWritable
void httpSetPipelineHandler (HttpConn *conn, HttpStage *handler)
void httpSetProtocol (HttpConn *conn, cchar *protocol)
void httpSetRetries (HttpConn *conn, int retries)
void httpSetSendConnector (HttpConn *conn, cchar *path)
void httpSetState (HttpConn *conn, int state)
void httpSetTimeout (HttpConn *conn, int requestTimeout, int inactivityTimeout)
int httpShouldTrace (HttpConn *conn, int dir, int item, cchar *ext)

Test if the item should be traced.

Parameters:
connHttpConn connection object created via $httpCreateConn.
dirDirection of data flow. Set to HTTP_TRACE_RX or HTTP_TRACE_TX.
itemItem to trace. Set to HTTP_TRACE_CONN, HTTP_TRACE_FIRST, HTTP_TRACE_HEADER, HTTP_TRACE_BODY, or HTTP_TRACE_TIME.
extURI resource extension (without ".").
Returns:
The level at which tracing should be done. Returns -1 if tracing should not be done for this item.
See Also:
HttpConn, HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnTimeout, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpGetKeepAliveCount, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetKeepAliveCount, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpStartPipeline, httpWritable
void httpStartPipeline (HttpConn *conn)
void httpWritable (HttpConn *conn)
ssize httpWriteUploadData (HttpConn *conn, MprList *formData, MprList *fileData)

Write Http upload body data.

Description:
Write files and form fields as request body data. This will use transfer chunk encoding. This routine will block until all the buffer is written even if a callback is defined.
Parameters:
connHttp connection object created via $httpCreateConn.
fileDataList of string file names to upload.
formDataList of strings containing "key=value" pairs. The form data should be already www-urlencoded.
Returns:
Number of bytes successfully written.
See Also:
HttpConn, HttpEnvCallback, HttpGetPassword, HttpListenCallback, HttpNotifier, HttpQueue, HttpRedirectCallback, HttpRx, HttpStage, HttpTx, httpCallEvent, httpCloseConn, httpConnTimeout, httpConnectorComplete, httpConsumeLastRequest, httpCreateConn, httpCreateRxPipeline, httpCreateTxPipeline, httpDestroyConn, httpDestroyPipeline, httpDiscardTransmitData, httpDisconnect, httpEnableUpload, httpError, httpEvent, httpGetAsync, httpGetChunkSize, httpGetConnContext, httpGetConnHost, httpGetError, httpGetExt, httpGetKeepAliveCount, httpMatchHost, httpMemoryError, httpPrepClientConn, httpPrepServerConn, httpProcessPipeline, httpResetCredentials, httpRouteRequest, httpSetAsync, httpSetChunkSize, httpSetConnContext, httpSetConnHost, httpSetConnNotifier, httpSetCredentials, httpSetKeepAliveCount, httpSetPipelineHandler, httpSetProtocol, httpSetRetries, httpSetSendConnector, httpSetState, httpSetTimeout, httpShouldTrace, httpStartPipeline, httpWritable

HttpEndpoint

HttpEndpoint

Listening endpoints.

API Stability:
Evolving.
See Also:
httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
Fields:
intasync Listening is in async mode (non-blocking).
intclientCount Count of current active clients.
MprHash *clientLoad Table of active client IPs and connection counts.
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.
HttpNotifiernotifier Default connection notifier callback.
intport Listen port.
intrequestCount Count of current active requests.
MprSocket *sock Listening socket.
struct MprSsl *ssl Endpoint SSL configuration.
MprWaitHandler *waitHandler I/O wait handler.
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.
See Also:
HttpEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
int httpConfigureNamedVirtualEndpoints (Http *http, cchar *ip, int port)

Configure endpoints with named virtual hosts.

Parameters:
httpHttp service object.
ipIP address for the named virtual host.
portaddress for the named virtual host.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
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.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
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
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
bool httpHasNamedVirtualHosts (HttpEndpoint *endpoint)

Test if an endpoint has named virtual hosts.

Parameters:
endpointEndpoint object to examine.
Returns:
True if the endpoint has named virutal hosts.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
void httpSetHasNamedVirtualHosts (HttpEndpoint *endpoint, bool on)

Control whether the endpoint has named virtual hosts.

Parameters:
endpointEndpoint object to examine.
onSet to true to enable named virtual hosts.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpStartEndpoint, httpStopEndpoint, httpValidateLimits
int httpStartEndpoint (HttpEndpoint *endpoint)

Start listening for client connections.

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.
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStopEndpoint, httpValidateLimits
void httpStopEndpoint (HttpEndpoint *endpoint)

Stop the server listening for client connections.

Description:
Closes the socket endpoint.
Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
See Also:
HttpEndpoint, httpAddHostToEndpoint, httpCreateEndpoint, httpDestroyEndpoint, httpHasNamedVirtualHosts, httpSetEndpointAddress, httpSetEndpointNotifier, httpSetHasNamedVirtualHosts, httpStartEndpoint, httpValidateLimits

HttpHost

HttpHost

Host Object.

Description:
A Host object represents a logical host. Several logical hosts may share a single HttpEndpoint.
API Stability:
Evolving.
See Also:
httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, httpSetHostName, httpSetHostProtocol
Fields:
HttpRoute *defaultRoute Default route for the host.
intflags Host flags.
char *home Directory for configuration files.
char *ip Hostname/ip portion parsed from name.
MprMutex *mutex Multithread sync.
char *name Host name.
struct HttpHost *parent Parent host to inherit aliases, dirs, routes.
intport Port address portion parsed from name.
char *protocol Defaults to "HTTP/1.1".
MprCache *responseCache Response content caching store.
MprList *routes List of Route defintions.
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.
See Also:
HttpHost, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, 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.
See Also:
HttpHost, httpAddRoute, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, httpSetHostName, httpSetHostProtocol
HttpHost * httpCreateHost ()

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.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, httpSetHostName, httpSetHostProtocol
void httpResetRoutes (HttpHost *host)

Reset the list of routes for the host.

Parameters:
hostHttpHost object.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpSetHostHome, httpSetHostIpAddr, httpSetHostName, httpSetHostProtocol
void httpSetHostHome (HttpHost *host, cchar *dir)

Set the home directory for a host.

Description:
The home directory is used by some host and route components to locate configuration files.
Parameters:
hostHttpHost object.
dirDirectory path for the host home.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostIpAddr, httpSetHostName, httpSetHostProtocol
void httpSetHostIpAddr (HttpHost *host, cchar *ip, int port)

Set the host internet address.

Description:
Set the host IP and port address.
Parameters:
hostHttpHost object.
ipInternet address. This can be an IP address or a symbolic domain and host name.
portPort number.
Returns:
"Zero" if the route can be added.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostName, httpSetHostProtocol
void httpSetHostName (HttpHost *host, cchar *name)

Set the host name.

Description:
The host name is used when matching virtual hosts with the Http Host header. The host name is also used for some redirections. in order, so it is important to define routes in the order in which you wish to match them.
Parameters:
hostHttpHost object.
nameHost name to use.
Returns:
Zero if the route can be added.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, 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.
See Also:
HttpHost, httpAddRoute, httpCloneHost, httpCreateHost, httpResetRoutes, httpSetHostHome, httpSetHostIpAddr, httpSetHostName

HttpLimits

HttpLimits

Http limits.

API Stability:
Evolving.
See Also:
httpCreateLimits, httpEaseLimits, httpEnableTraceMethod, httpInitLimits
Fields:
ssizecacheItemSize Maximum size of a cachable item.
ssizechunkSize Maximum chunk size for transfer encoding.
intclientCount Maximum number of simultaneous clients endpoints.
intenableTraceMethod Trace method enabled.
intheaderCount Maximum number of header lines.
ssizeheaderSize Maximum size of the total header.
MprTimeinactivityTimeout Default timeout for keep-alive and idle requests (msec).
intkeepAliveCount Maximum number of Keep-Alive requests to perform per socket.
MprOffreceiveBodySize Maximum size of receive body data.
MprOffreceiveFormSize Maximum size of form data.
intrequestCount Maximum number of simultaneous concurrent requests.
MprTimerequestTimeout Default time a request can take (msec).
MprTimesessionTimeout Default time a session can persist (msec).
ssizestageBufferSize Maximum buffering by any pipeline stage.
MprOfftransmissionBodySize Maximum size of transmission body content.
MprOffuploadSize Maximum size of an uploaded file.
ssizeuriSize Maximum size of a uri.
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.
See Also:
HttpLimits, httpEaseLimits, httpEnableTraceMethod, 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.
Parameters:
limitsLimits object. This can be either HttpHost.limits HttpConn.limits or HttpEndpoint.limits.
See Also:
HttpLimits, httpCreateLimits, httpEnableTraceMethod, httpInitLimits
void httpEnableTraceMethod (struct HttpLimits *limits, bool on)

Enable use of the TRACE Http method by the object owning the limits object.

Parameters:
limitsLimits.
onSet to true to enable the trace method.
onSet to 1 to enable.
See Also:
HttpLimits, httpCreateLimits, httpEaseLimits, 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.
See Also:
HttpLimits, httpCreateLimits, httpEaseLimits, httpEnableTraceMethod

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.
API Stability:
Evolving.
See Also:
HttpFillProc, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
Fields:
MprBuf *content Chunk content.
MprOffepos Data position in entity (file).
MprOffesize Data size in entity (file).
HttpFillProcfill Callback to fill packet with data.
intflags Packet flags.
struct HttpPacket *next Next packet in chain.
MprBuf *prefix Prefix message to be emitted before the content.
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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreateEndPacket ()

Create an eof 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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, 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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpPacket * httpCreateHeaderPacket ()

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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, 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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpGetPacket, httpGetPacketLength, 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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, 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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, 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.
Parameters:
packetPacket to split.
offsetRoute in the original packet at which to split.
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.
See Also:
HttpFillProc, HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, 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.
API Stability:
Evolving.
See Also:
HttpConn, HttpPacket, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
Fields:
HttpQueueCloseclose Close the queue.
struct HttpConn *conn Connection owning this 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 for sendfile.
HttpPacket *last Last packet in queue (tail pointer).
ssizelow Low water mark for flow control.
ssizemax Maxiumum queue size.
struct HttpQueue *nextQ Downstream queue for next stage.
HttpQueueOpenopen Open the queue.
cchar *owner Name of owning stage.
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 Put a message on the queue.
void *queueData Stage instance data.
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 httpDisableQueue (HttpQueue *q)
void httpDiscardData (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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
void httpEnableQueue (HttpQueue *q)
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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
ssize httpGetQueueRoom (HttpQueue *q)
bool httpIsEof (struct HttpConn *conn)

Test if the connection has received all incoming content.

Description:
This tests if the connection is at an "End of File condition.
Parameters:
connHttpConn object created via $httpCreateConn.
Returns:
"True" if all Receive content has been received.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
void httpJoinPackets (HttpQueue *q, ssize size)

Join the packets together.

Description:
This call joins data packets (on the given queue) together - up to the designated maximum size. The maximum size is 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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
void httpPutForService (struct HttpQueue *q, HttpPacket *packet, bool serviceQ)

Put a packet onto the service queue.

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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
void httpPutPacket (struct HttpQueue *q, HttpPacket *packet)
void httpPutPacketToNext (struct HttpQueue *q, HttpPacket *packet)

Put a packet onto the next queue.

Description:
Put a packet onto the next downstream queue by calling the downstream queue's put() method.
Parameters:
qQueue reference. The packet will not be queued on this queue, but rather on the queue downstream.
packetPacket to put.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
int 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.
packetPacket to put.
sizeIf size is > 0, then also ensure the packet is not larger than this size.
Returns:
"Zero" if successful, otherwise a negative Mpr error code.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWrite, httpWriteBlock, httpWriteString
void httpScheduleQueue (HttpQueue *q)
void httpSendEndPacket (HttpQueue *q)
void httpSendPackets (HttpQueue *q)
void httpServiceQueue (HttpQueue *q)
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 $httpSendPacketToNext to send the packet downstream.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, 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 may block waiting for the downstream queue to drain if it is or becomes full.
Parameters:
qQueue reference.
fmtPrintf style formatted string.
...Arguments for fmt.
Returns:
A count of the bytes actually written.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, httpWriteBlock, httpWriteString
ssize httpWriteBlock (HttpQueue *q, cchar *buf, ssize size)

Write a block of data to the queue.

Description:
Write a block of data into packets onto the end of the queue. Data packets will be created as required to store the write data. This call will either accept and write all the data or it will fail. It will never return "short", i.e. with a partial write.
Parameters:
qQueue reference.
bufBuffer containing the write data.
sizeof the data in buf.
Returns:
The size value if successful or a negative MPR error code.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
Parameters:
qQueue reference.
sString containing the data to write.
Returns:
A count of the bytes actually written.
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.
Parameters:
qQueue reference.
sString containing the data to write.
Returns:
A count of the bytes actually written.
See Also:
HttpConn, HttpPacket, HttpQueue, httpDisableQueue, httpDiscardData, httpEnableQueue, httpGetQueueRoom, httpIsEof, httpIsPacketTooBig, httpIsQueueEmpty, httpJoinPacketForService, httpJoinPackets, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpRemoveQueue, httpResizePacket, httpScheduleQueue, httpSendEndPacket, httpSendPackets, httpServiceQueue, httpWillNextQueueAcceptSize, 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.
API Stability:
Evolving.
See Also:
Fields:
MprOffend End byte of range + 1.
MprOfflen Redundant range length.
struct HttpRange *next Next range.
MprOffstart Start of range.

HttpRoute

HttpRoute

Route Control.

API Stability:
Evolving.
See Also:
httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
Fields:
HttpAuth *auth Per route block authentication.
intautoDelete Automatically delete uploaded files.
MprList *caching Items to cache.
MprList *conditions Route conditions.
HttpStage *connector Network connector to use.
void *context Hosting context (Appweb == EjsPool).
MprHash *data Hash of extra data configuration.
char *defaultLanguage Default language.
char *dir Directory filename.
void *eroute Extended route information for handler (only).
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 *handlersWithMatch List of handlers with match routines.
MprList *headers Matching header values.
struct HttpHost *host Owning host.
Http *http Http service object (copy of appweb->http).
MprList *indicies Directory index documents.
MprList *inputStages Input stages.
MprHash *languages Languages supported.
MprTimelifespan Default lifespan for all cache items in route.
HttpLimits *limits Host resource limits.
MprFile *log File object for access logging.
intlogBackup Number of log backups.
intlogFlags Log control flags (append|anew).
char *logFormat Access log format.
char *logPath Access log filename.
ssizelogSize Max log size.
MprHash *methods Matching HTTP methods.
char *methodSpec Supported HTTP methods.
MprHash *mimeTypes Hash table of mime types (key is extension).
char *name Route name.
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.
MprHash *pathTokens Path $token refrerences.
char *pattern Original matching URI pattern for the route (includes prefix).
void *patternCompiled Compiled pattern regular expression (not alloced).
char *prefix Application scriptName prefix.
ssizeprefixLen Prefix length.
intresponseStatus Response status code.
char *script Startup script for handlers serving this route.
char *scriptPath Startup script path for handlers serving this route.
char *sourceName Source name for route target.
char *sourcePath Source path for route target.
struct MprSsl *ssl SSL configuration.
char *startSegment Starting literal segment of pattern (includes prefix).
ssizestartSegmentLen Prefix length.
char *startWith Starting literal segment of pattern (includes prefix).
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).
HttpTracetrace[2] Default route request tracing.
inttraceMask Request/response trace mask.
MprList *updates Route and request updates.
char *uploadDir Upload directory.
intworkers Number of workers to use for this route.
void httpAddHomeRoute (HttpRoute *parent)
void httpAddResource (HttpRoute *parent, cchar *resource)
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
listGET/NAME(/)*$list
initGET/NAME/init$init
createPOST/NAME(/)*$create
editGET/NAME/{id=[0-9]+}/edit$edit
showGET/NAME/{id=[0-9]+}$show
updatePUT/NAME/{id=[0-9]+}$update
destroyDELETE/NAME/{id=[0-9]+}$destroy
customPOST/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.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, 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.
See Also:
HttpRoute, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteErrorDocument (HttpRoute *route, int status, cchar *uri)
void httpAddRouteExpiry (HttpRoute *route, MprTime when, cchar *extensions)

Cache response content in the client by extension.

Description:
This configures default caching lifespans for documents with various extensions. This call causes a Cache-Control header to be sent with the response instructing the client to cache the response content. This is most useful for client caching static web content. For example: to cache "png" graphic files, use: httpAddRouteExpiry(route, when, "png");.
Parameters:
routeRoute to modify.
whenTime to expire the item. Use mprGetTime() + milliseconds.
extensionsSpace or comma separated list of request extensions for which the content should be cached in the client.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteExpiryByType (HttpRoute *route, MprTime when, cchar *mimeTypes)

Cache response content in the client by mime type.

Add client cache expiry definitions to the route
Description:
This configures default caching lifespans for documents with various mime types. The call causes a Cache-Control header to be sent with the response instructing the client to cache the response content. It is most useful for client caching static web content. For example: to cache "png" graphic files, use: httpAddRouteExpiry(route, when, "png");.
Parameters:
routeRoute to modify.
whenTime to expire the item. Use mprGetTime() + milliseconds.
mimeTypesSpace or command separated list of response mime types for which the content should be cached in the client.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
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.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpAddRouteHandler (HttpRoute *route, cchar *name, cchar *extensions)
void httpAddRouteHeader (HttpRoute *route, cchar *header, cchar *value, int flags)
void httpAddRouteIndex (HttpRoute *route, cchar *path)
int httpAddRouteLanguageDir (HttpRoute *route, cchar *language, cchar *path)
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.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddRouteParam (HttpRoute *route, cchar *field, cchar *value, int flags)
void httpAddRouteSet (HttpRoute *parent, cchar *set)

Add a route set package.

Description:
This will add a set of routes suitable for some application paradigms.
NameMethodPatternTarget
homeGET,POST,PUT^/$index.esp
staticGET^/static(/(.)*$$1
Parameters:
parentParent route from which to inherit configuration.
setRoute set to select. Use "simple", "mvc", "restful" or "none".

The "simple" pack will invoke httpAddHomeRoute and httpAddStaticRoute to add "home", and "static" routes.

The "mvc" selection will add the default routes and then add the route:
NameMethodPatternTarget
default*^/{controller}(~/{action}~)$${controller}-${action}


See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
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.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpAddStaticRoute (HttpRoute *parent)
void httpBackupRouteLog (HttpRoute *route)
void httpClearRouteStages (HttpRoute *route, int direction)
HttpRoute * httpCreateAliasRoute (HttpRoute *parent, cchar *pattern, cchar *path, int status)
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 *name, 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.
nameRoute name to define.
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.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpDefineRouteCondition (cchar *name, HttpRouteProc *proc)
void httpDefineRouteTarget (cchar *name, HttpRouteProc *proc)
void httpDefineRouteUpdate (cchar *name, HttpRouteProc *proc)
void httpFinalizeRoute (HttpRoute *route)
HttpRoute * httpGetHostDefaultRoute (HttpHost *host)
MprHash * httpGetOptionHash (MprHash *options, cchar *field)
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:
cchar * httpGetRouteDir (HttpRoute *route)
cchar * httpGetRouteMethods (HttpRoute *route)
HttpLimits * httpGraduateLimits (HttpRoute *route)
void httpLogRoutes (HttpHost *host, bool full)
cchar * httpLookupRouteErrorDocument (HttpRoute *route, int status)
char * httpMakePath (HttpRoute *route, cchar *path)

Make a filename path.

Description:
This makes a filename by expanding the tokens "${token}" and then normalizing the path and converting to an absolute path name. The supported tokens are:
  • PRODUCT - for the product name
  • OS - for the operating system name. E.g. LINUX, MACOSX, VXWORKS, or WIN
  • VERSION - for the product version. E.g. 4.0.2
  • LIBDIR - for the library directory. E.g. /usr/lib/appweb
  • DOCUMENT_ROOT - for the default directory containing documents to serve
  • SERVER_ROOT - for the directory containing the web server configuration files
Additional tokens can be defined via httpSetRoutePathVar
Parameters:
routeRoute to modify.
pathPath name to examine.
Returns:
An absolute file name.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
int httpMatchRoute (HttpConn *conn, HttpRoute *route)
void httpRemoveOption (MprHash *options, cchar *field)
void httpResetRoutePipeline (HttpRoute *route)
void httpSetHostDefaultRoute (HttpHost *host, HttpRoute *route)
void httpSetOption (MprHash *options, cchar *field, cchar *value)
void httpSetRouteAuth (HttpRoute *route, HttpAuth *auth)
void httpSetRouteAutoDelete (HttpRoute *route, bool on)
void httpSetRouteCompression (HttpRoute *route, int flags)
int httpSetRouteConnector (HttpRoute *route, cchar *name)
void httpSetRouteData (HttpRoute *route, cchar *key, void *data)
void httpSetRouteDefaultLanguage (HttpRoute *route, cchar *language)
void httpSetRouteDir (HttpRoute *route, cchar *dir)
void httpSetRouteFlags (HttpRoute *route, int flags)
int httpSetRouteHandler (HttpRoute *route, cchar *name)
void httpSetRouteLog (HttpRoute *route, cchar *path, ssize size, int backup, cchar *format, int flags)
void httpSetRouteMethods (HttpRoute *route, cchar *methods)
void httpSetRouteName (HttpRoute *route, cchar *name)
void httpSetRoutePathVar (HttpRoute *route, cchar *token, cchar *value)
void httpSetRoutePattern (HttpRoute *route, cchar *pattern, int flags)

Set the route pattern.

Description:
This call defines the route regular expression pattern that is used to match against the request URI. The route pattern is an enhanced JavaScript-compatibile regular expression. It is enhanced by optionally embedding braced tokens "{name}" in the patter. During request URI matching, these tokens are extracted and defined in the request params and are available to the request. The normal regular expression repeat syntax also uses "{}". To use the traditional (uncommon) repeat syntax, back quote with "\\". Sub-expressions and token expressions are also available in various rules as numbered tokens "$1". For example: the pattern "/app/(.*)(\.html)$" will permit a file target "$1.${request.Language=fr}.$2".
Parameters:
routeRoute to modify.
patternRoute regular expression pattern.
flagsSet to HTTP_ROUTE_NOT to negate the pattern match result.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpSetRoutePrefix (HttpRoute *route, cchar *prefix)
void httpSetRouteScript (HttpRoute *route, cchar *script, cchar *scriptPath)
void httpSetRouteSource (HttpRoute *route, cchar *source)
int httpSetRouteTarget (HttpRoute *route, cchar *name, cchar *details)

Set a route target.

Description:
This configures the route pipeline by defining a route target. The route target is interpreted by the selected route handler to process the request. Route targets can contain symbolic tokens that are expanded at run-time with their corresponding values. There are three classes of tokens:
  • System varibles - such as DOCUMENT_ROOT, LIBDIR, PRODUCT, OS, SERVER_ROOT, VERSION.
  • Route URI tokens - these are the braced tokens in the route pattern.
  • Request fields - these are request state and property values.
System and URI tokens are of the form: "${token}" where "token" is the name of the variable or URI token. Request fields are of the form: "${family:name=defaultValue}" where the family defines a set of values. If the named field is not present, an optional default value "=defaultValue" will be used instead. These supported request field families are:
  • header - for request HTTP header values
  • param - for request params
  • query - for request query field values
  • request - for request details
  • Any URI pattern token
For example: "run ${header:User-Agent}" to select the client's browser string passed in the HTTP headers. For example: "run ${field:name}" to select the client's browser string passed in the HTTP headers. For example: "run ${name}.html" where {name} was a token in the route pattern. For example: "run ${name}.html" where {name} was a token in the route pattern. The supported request key names are:
  • clientAddress - The client IP address
  • clientPort - The client port number
  • error - Any request or connection error message
  • ext - The request extension
  • extraPath - The request extra path after the script extension
  • filename - The mapped request filename in physical storage
  • language - The selected language for the request
  • languageDir - The langauge directory
  • host - The host name owning the route for the request
  • method - The request HTTP method
  • originalUri - The original, pre-decoded URI
  • pathInfo - The path portion of the URI after the host and port information
  • prefix - The route prefix
  • query - The request query information
  • reference - The request reference fragment. This is the URI portion after "#"
  • scheme - The request protocol scheme. E.g. "http"
  • scriptName - The request script or application name
  • serverAddress - The server IP address
  • serverPort - The server port number
  • uri - The full request URI. May be modified by routes, handlers and filters
Also see httpMakePath for additional tokens (DOCUMENT_ROOT, LIBDIR, PRODUCT, OS, SERVER_ROOT, VERSION).
Parameters:
routeRoute to modify.
nameTarget rule to add. Supported update rules include: "close", "redirect", "run" and "write".

The "close" rule is used to do abortive closes for the request. This is useful for ward off known security attackers. For example: "close immediate". The "close" rule takes no addition parameters.



The "redirect" rule is used to redirect the request to a new resource. For example: "redirect 302 /tryAgain.html". The "redirect" takes the form: "redirect status URI". The status code is used as the HTTP response code. The URI can be a fully qualified URI beginning with "http" or it can be a relative URI.

The "run" target is used to run the configured handler to respond to the request. For example: "file ${DOCUMENT_ROOT}/${request.uri}.gz".

The "write" rule is used to write literal data back to the client. For example: "write 200 Hello World\r\n". The "write" rule takes the form: "write [-r] status message". Write data is by default HTML encoded to help eliminate XSS security exposures. The "-r" option selects "raw" output and bypasses the HTML encoding of the write data string.

WARNING: Take great care when using raw writes with tokens. Write data is not HTML encoded and echoing back to raw data to the client can cause XSS and other security issues. The status field defines the HTTP status code to use in the response.
detailsUpdate rule parameters.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpSetRouteTemplate (HttpRoute *route, cchar *tplate)
void httpSetRouteTraceFilter (HttpRoute *route, int dir, int levels, ssize len, cchar *include, cchar *exclude)

Set the route trace filter.

Description:
Trace filters include or exclude trace items based on the request filename extension.
Parameters:
routeHttpRoute object.
dirTrace direction. Set to HTTP_TRACE_TX or HTTP_TRACE_RX.
levelsTrace class levels. Indicies are: HTTP_TRACE_CONN, HTTP_TRACE_FIRST, HTTP_TRACE_HEADER, HTTP_TRACE_BODY, HTTP_TRACE_LIMITS, HTTP_TRACE_TIME.
lenMaximum content length eligible for tracing.
includeComma or space separated list of extensions to include in tracing.
excludeComma or space separated list of extensions to exclude from tracing.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenize, httpTokenizev
void httpSetRouteWorkers (HttpRoute *route, int workers)
void httpSetStageData (struct HttpConn *conn, cchar *key, cvoid *data)
char * httpTemplate (HttpConn *conn, cchar *tplate, MprHash *options)
bool httpTokenize (HttpRoute *route, cchar *str, cchar *fmt, ...)

Tokenize a string based on route data.

Description:
This is a utility routine to parse a string into tokens given a format specifier. Mandatory tokens can be specified with "%" format specifier. Optional tokens are specified with "?" format. Supported tokens:
  • B - Boolean. Parses: on/off, true/false, yes/no.
  • N - Number. Parses numbers in base 10.
  • S - String. Removes quotes.
  • P - Path string. Removes quotes and expands ${PathVars}. Resolved relative to host->dir (ServerRoot).
  • W - Parse words into a list
  • ! - Optional negate. Set value to HTTP_ROUTE_NOT present, otherwise zero.
Values wrapped in quotes will have the outermost quotes trimmed.
Parameters:
routeRoute to modify.
strString to expand.
fmtFormat string specifier.
Returns:
True if the string can be successfully parsed.
See Also:
HttpRoute, httpAddRouteCondition, httpAddRouteErrorDocument, httpAddRouteExpiry, httpAddRouteExpiryByType, httpAddRouteFilter, httpAddRouteHandler, httpAddRouteHeader, httpAddRouteLanguageDir, httpAddRouteLanguageSuffix, httpAddRouteUpdate, httpClearRouteStages, httpCreateAliasRoute, httpCreateDefaultRoute, httpCreateInheritedRoute, httpCreateRoute, httpDefineRoute, httpDefineRouteCondition, httpDefineRouteTarget, httpDefineRouteUpdate, httpFinalizeRoute, httpGetRouteData, httpGetRouteDir, httpLookupRouteErrorDocument, httpMakePath, httpMatchRoute, httpResetRoutePipeline, httpSetRouteAuth, httpSetRouteAutoDelete, httpSetRouteCompression, httpSetRouteConnector, httpSetRouteData, httpSetRouteDefaultLanguage, httpSetRouteDir, httpSetRouteFlags, httpSetRouteHandler, httpSetRouteMethods, httpSetRouteName, httpSetRoutePathVar, httpSetRoutePattern, httpSetRoutePrefix, httpSetRouteScript, httpSetRouteSource, httpSetRouteTarget, httpSetRouteWorkers, httpTemplate, httpTokenizev
bool httpTokenizev (HttpRoute *route, cchar *str, cchar *fmt, va_list args)
void httpWriteRouteLog (HttpRoute *route, cchar *buf, ssize len)

HttpRx

HttpRx

Http Rx.

Description:
Most of the APIs in the rx group still take a HttpConn object as their first parameter. This is to make the API easier to remember - APIs take a connection object rather than a rx or tx object.
API Stability:
Evolving.
See Also:
HttpConn, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
Fields:
char *accept Accept header.
char *acceptCharset Accept-Charset header.
char *acceptEncoding Accept-Encoding header.
char *acceptLanguage Accept-Language header.
intauthenticated Request has been authenticated.
char *authType Authorization type (basic|digest) (ENV: AUTH_TYPE).
intautoDelete Automatically delete uploaded files.
MprOffbytesRead Length of content read by user.
intchunkState Chunk encoding state.
HttpConn *conn Connection object.
char *connection Connection header.
char *contentLength Content length string value.
char *cookie Cookie header.
inteof All read data has been received (eof).
MprList *etags Document etag to uniquely identify the document version.
char *extraPath Extra path information (CGI|PHP).
MprHash *files Uploaded files. Managed by the upload filter.
intflags Rx modifiers.
intform Using mime-type application/x-www-form-urlencoded.
HttpPacket *headerPacket HTTP headers.
MprHash *headers Header variables.
char *hostHeader Client supplied host name header.
boolifMatch If-Match processing requested.
boolifModified If-Modified processing requested.
MprList *inputPipeline Input processing.
HttpRange *inputRange Specified range for rx (post) data.
HttpLang *lang Selected language.
MprOfflength Content length header value (ENV: CONTENT_LENGTH).
char *method Request method.
char *mimeType Mime type of the request payload (ENV: CONTENT_TYPE).
intneedInputPipeline Input pipeline required to process received data.
char *originalMethod Original method from the client.
char *originalUri Original URI passed by the client.
MprHash *params Request params (Query and post data variables).
char *paramString Cached param data as a string.
HttpUri *parsedUri Parsed request uri.
char *pathInfo Path information after the scriptName (Decoded and normalized).
char *pragma Pragma header.
char *redirect Redirect route header.
char *referrer Refering URL.
MprOffremainingContent Remaining content data to read (in next chunk if chunked).
MprHash *requestData General request data storage. Users must create hash table if required.
HttpRoute *route Route for request.
char *scriptName ScriptName portion of the uri (Decoded). May be empty or start with "/".
char *securityToken Security form token.
MprTimesince If-Modified date.
intstatus HTTP response status.
char *statusMessage HTTP Response status message.
intstreamInput Streaming read data. Means !form.
MprHash *svars Server variables.
char *target Route target.
inttraceLevel General trace level for header level info.
intupload Request is using file upload.
char *uploadDir Upload directory.
char *uri Current URI (not decoded, may be rewritten).
char *userAgent User-Agent header.
void httpAddParams (HttpConn *conn)
bool httpContentNotModified (HttpConn *conn)

Test if the content has not been modified.

Description:
This call tests if the file content to be served has been modified since the client last requested this resource. The client must provide an Etag and Since or If-Modified headers.
Parameters:
connHttpConn connection object.
Returns:
True if the content is current and has not been modified.
See Also:
HttpConn, HttpRx, HttpTx, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
void httpCreateCGIParams (HttpConn *conn)

Create CGI parameters.

Description:
This call creates request params corresponding to the standard CGI/1.1 environment variables. This is used by the CGI and PHP handlers. It may also be useful to handlers that wish to expose CGI style environment variables through the form vars interface.
Parameters:
connHttpConn connection object.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
MprOff httpGetContentLength (HttpConn *conn)

Get the receive body content length.

Description:
Get the length of the receive body content (if any). This is used in servers to get the length of posted data and in clients to get the response body length.
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
A count of the response content data in bytes.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
cchar * httpGetCookies (HttpConn *conn)

Get the request cookies.

Description:
Get the cookies defined in the current requeset.
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
Return a string containing the cookies sent in the Http header of the last request.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
cchar * httpGetHeader (HttpConn *conn, cchar *key)

Get an rx http header.

Description:
Get a http response header for a given header key.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyName of the header to retrieve. This should be a lower case header name. For example: "Connection".
Returns:
Value associated with the header key or null if the key did not exist in the response.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
MprHash * httpGetHeaderHash (HttpConn *conn)

Get the hash table of rx Http headers.

Description:
Get the internal hash table of rx headers.
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
Hash table. See MprHash for how to access the hash table.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
char * httpGetHeaders (HttpConn *conn)

Get all the request http headers.

Description:
Get all the rx headers. The returned string formats all the headers in the form: key: value\nkey2: value2\n.
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
String containing all the headers. The caller must free this returned string.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
char * httpGetHeadersFromHash (MprHash *hash)
int httpGetIntParam (HttpConn *conn, cchar *var, int defaultValue)

Get a form variable as an integer.

Description:
Get the value of a named form variable as an integer. Form variables are define via www-urlencoded query or post data contained in the request.
Parameters:
connHttpConn connection object.
varName of the form variable to retrieve.
defaultValueDefault value to return if the variable is not defined. Can be null.
Returns:
Integer containing the form variable's value.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
HttpLang * httpGetLanguage (HttpConn *conn, MprHash *spoken, cchar *defaultLang)

Get the language to use for the request.

Description:
This call tests if the file content to be served has been modified since the client last requested this resource. The client must provide an Etag and Since or If-Modified headers.
Parameters:
connHttpConn connection object.
spokenHash table of HttpLang records. This is typically route->languages.
defaultLangDefault language to use if none specified in the request Accept-Language header.
Returns:
A HttpLang reference, or null if no language requested or no language found in the spoken table.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
cchar * httpGetParam (HttpConn *conn, cchar *var, cchar *defaultValue)

Get a request param.

Description:
Get the value of a named request param. Form variables are define via www-urlencoded query or post data contained in the request.
Parameters:
connHttpConn connection object.
varName of the request param to retrieve.
defaultValueDefault value to return if the variable is not defined. Can be null.
Returns:
String containing the request param's value. Caller should not free.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
MprHash * httpGetParams (HttpConn *conn)

Get the request params table.

Description:
This call gets the form var table for the current request. Query data and www-url encoded form data is entered into the table after decoding. Use mprLookupKey to retrieve data from the table.
Parameters:
connHttpConn connection object.
Returns:
MprHash instance containing the form vars.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
char * httpGetParamsString (HttpConn *conn)

Get the request params table as a string.

Description:
This call gets the request params encoded as a string. The params are always in the same order regardless of the form parameter order. Request parameters include query parameters, form data and routing parameters.
Parameters:
connHttpConn connection object.
Returns:
A string representation in www-urlencoded format.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
cchar * httpGetQueryString (HttpConn *conn)

Get the request query string.

Description:
Get query string sent with the current request.
Parameters:
connHttpConn connection object.
Returns:
String containing the request query string. Caller should not free.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
cvoid * httpGetStageData (struct HttpConn *conn, cchar *key)

Get stage data.

Description:
Stages can store extra configuration information indexed by key. This is used by handlers, filters, connectors and and handlers.
Parameters:
connHttpConn connection object.
keyKey index into the stage data.
Returns:
A reference to the stage data. Otherwise return null if the route data for the given key was not found.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
int httpGetStatus (HttpConn *conn)
char * httpGetStatusMessage (HttpConn *conn)

Get the Http response status message.

The Http status message is supplied on the first line of the Http response
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
A Http status message.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
bool httpMatchParam (HttpConn *conn, cchar *var, cchar *expected)

Match a form variable with an expected value.

Description:
Compare a form variable and return true if it exists and its value matches.
Parameters:
connHttpConn connection object.
varName of the form variable.
expectedExpected value to match with.
Returns:
True if the value matches.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
ssize httpRead (HttpConn *conn, char *buffer, ssize size)

Read rx body data.

This will read available body data. If in sync mode, this call may block. If in async mode, the call will not block and will return with whatever data is available
Parameters:
connHttpConn connection object created via $httpCreateConn.
bufferBuffer to receive read data.
sizeSize of buffer.
Returns:
The number of bytes read.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
char * httpReadString (HttpConn *conn)

Read response data as a string.

This will read all rx body and return a string that the caller should free. This will block and should not be used in async mode
Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
A string containing the rx body. Caller should free.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
void 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.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
void httpSetIntParam (HttpConn *conn, cchar *var, int value)

Set an integer request param value.

Description:
Set the value of a named request param to an integer value. Form variables are define via www-urlencoded query or post data contained in the request.
Parameters:
connHttpConn connection object.
varName of the request param to retrieve.
valueDefault value to return if the variable is not defined. Can be null.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
void httpSetMethod (HttpConn *conn, cchar *method)

Set a new HTTP method for processing.

Description:
This modifies the request method to alter request processing. The original method is preserved in the HttpRx.originalMethod field. This is only useful to do before request routing has matched a route.
Parameters:
connHttpConn connection object.
methodNew method to use.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
void httpSetParam (HttpConn *conn, cchar *var, cchar *value)

Set a request param value.

Description:
Set the value of a named request param to a string value. Form variables are define via www-urlencoded query or post data contained in the request.
Parameters:
connHttpConn connection object.
varName of the request param to retrieve.
valueDefault value to return if the variable is not defined. Can be null.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
int httpSetUri (HttpConn *conn, cchar *uri, cchar *query)

Set a new URI for processing.

Description:
This modifies the request URI to alter request processing. The original URI is preserved in the HttpRx.originalUri field. This is only useful to do before request routing has matched a route.
Parameters:
connHttpConn connection object.
uriNew URI to use. The URI can be fully qualified starting with a scheme ("http") or it can be a partial/relative URI. Missing portions of the URI will be completed with equivalent portions from the current URI. For example: if the current request URI was http://example.com:7777/index.html, then a call to httpSetUri(conn, "/new.html", 0) will set the request URI to http://example.com:7777/new.html. The request script name will be reset and the pathInfo will be set to the path portion of the URI.
queryOptional query string to define with the new URI. If query is null, any query string defined with the previous URI will be used. If query is set to the empty string, a previous query will be discarded.
Returns:
"Zero" if successful, otherwise a negative MPR error code.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath
int httpTestParam (HttpConn *conn, cchar *var)
void httpTrimExtraPath (HttpConn *conn)

Trim extra path from the URI.

Description:
This call trims extra path information after the uri extension. This is used by CGI and PHP. The strategy is to heuristically find the script name in the uri. This is assumed to be the original uri up to and including first path component containing a "." Any path information after that is regarded as extra path. WARNING: Extra path is an old, unreliable, CGI specific technique. Do not use directories with embedded periods.
Parameters:
connHttpConn connection object.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam
bool httpValidateLimits (HttpEndpoint *endpoint, int event, HttpConn *conn)

Validate the request against defined resource limits.

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:
endpointThe endpoint on which the server was listening.
eventProcessing event. The supported events are: HTTP_VALIDATE_OPEN_CONN, HTTP_VALIDATE_CLOSE_CONN, HTTP_VALIDATE_OPEN_REQUEST and HTTP_VALIDATE_CLOSE_REQUEST.
connHttpConn connection object.
Returns:
True if the request can be successfully validated against the endpoint limits.
See Also:
HttpConn, HttpRx, HttpTx, httpContentNotModified, httpCreateCGIParams, httpGetContentLength, httpGetCookies, httpGetHeader, httpGetHeaderHash, httpGetHeaders, httpGetIntParam, httpGetLanguage, httpGetParam, httpGetParams, httpGetQueryString, httpGetStatus, httpGetStatusMessage, httpMatchParam, httpRead, httpReadString, httpSetIntParam, httpSetParam, httpSetUri, httpSetWriteBlocked, httpTestParam, httpTrimExtraPath

HttpStage

HttpStage

Pipeline Stages.

Description:
The request pipeline consists of a full-duplex pipeline of stages. Stages are used to process client HTTP requests in a modular fashion. Each stage either creates, filters or consumes data packets. The HttpStage structure describes the stage capabilities and callbacks. Each stage has two queues, one for outgoing data and one for incoming data.

Stages provide callback methods for parsing configuration, matching requests, open/close, run and the acceptance and service of incoming and outgoing data.
API Stability:
Evolving.
See Also:
HttpConn, HttpQueue, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
Fields:
int(*check)(struct HttpConn *conn, struct HttpRoute *route) Check a request. Description:Check a fully routed request. A handler is given one last chance to accept, reject or reroute a request before processing. connHttpConn connection object stageStage object HTTP_ROUTE_OK if the request is acceptable. Return HTTP_ROUTE_REROUTE if the request is rewritten. Return HTTP_ROUTE_REJECT it the request is not acceptable.
void(*close)(HttpQueue *q) Close the queue. Description:Close the queue instance qQueue instance object
MprHash *extensions Matching extensions for this filter.
intflags Stage flags.
void(*incomingData)(HttpQueue *q, HttpPacket *packet) Process incoming data. Description:Accept an incoming packet of data qQueue instance object packetPacket of data
void(*incomingService)(HttpQueue *q) Service the incoming data queue. qQueue instance object
int(*match)(struct HttpConn *conn, struct HttpRoute *route, int dir) Match a request. Description:This procedure is invoked to see if the stage wishes to handle the request. If a stage denies to handle a request, it will be removed from the pipeline for the specified direction. connHttpConn connection object stageStage object dirDirection. Set to HTTP_RX or HTTP_TX. A filter may be placed in the tx, rx or both pipeline directions. The direction flag indicates what pipeline direction is being considered. HTTP_ROUTE_OK if the request is acceptable, HTTP_ROUTE_REJECT it the request is not acceptable, and return HTTP_ROUTE_REROUTE if the request is rewritten.
MprModule *module Backing module.
char *name Stage name.
void(*open)(HttpQueue *q) Open the queue. Description:Open the queue instance and initialize for this request. qQueue instance object
void(*outgoingData)(HttpQueue *q, HttpPacket *packet) Process outgoing data. Description:Accept a packet as outgoing data qQueue instance object packetPacket of data
void(*outgoingService)(HttpQueue *q) Service the outgoing data queue. qQueue instance object
char *path Backing module path (from LoadModule).
void(*process)(HttpQueue *q) Process the data. Description:All incoming data has been received. The handler can now complete the request. qQueue instance object
void *stageData Private stage data.
void(*start)(HttpQueue *q) Start the handler. Description:The request has been parsed and the handler may start processing. Input data may not have been received yet. qQueue instance object
HttpStage * httpCloneStage (Http *http, HttpStage *stage)

Create a clone of an existing state.

This is used when creating filters configured to match certain extensions
Parameters:
httpHttp object returned from httpCreate
stageStage object to clone.
Returns:
A new stage object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
HttpStage * httpCreateConnector (Http *http, cchar *name, int flags, MprModule *module)

Create a connector stage.

Description:
Create a new connector. Connectors are the final stage for outgoing data. Their job is to transmit outgoing data to the client.
Parameters:
httpHttp object returned from httpCreate
nameName of connector stage.
flagsStage flags mask. These specify what Http request methods will be supported by this stage. Or together any of the following flags:
  • HTTP_STAGE_DELETE - Support DELETE requests
  • HTTP_STAGE_GET - Support GET requests
  • HTTP_STAGE_HEAD - Support HEAD requests
  • HTTP_STAGE_OPTIONS - Support OPTIONS requests
  • HTTP_STAGE_POST - Support POST requests
  • HTTP_STAGE_PUT - Support PUT requests
  • HTTP_STAGE_TRACE - Support TRACE requests
  • HTTP_STAGE_ALL - Mask to support all methods
moduleOptional module object for loadable stages.
Returns:
A new stage object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
HttpStage * httpCreateFilter (Http *http, cchar *name, int flags, MprModule *module)

Create a filter stage.

Description:
Create a new filter. Filters transform data generated by handlers and before connectors transmit to the client. Filters can apply transformations to incoming, outgoing or bi-directional data.
Parameters:
httpHttp object.
nameName of connector stage.
flagsStage flags mask. These specify what Http request methods will be supported by this stage. Or together any of the following flags:
  • HTTP_STAGE_DELETE - Support DELETE requests
  • HTTP_STAGE_GET - Support GET requests
  • HTTP_STAGE_HEAD - Support HEAD requests
  • HTTP_STAGE_OPTIONS - Support OPTIONS requests
  • HTTP_STAGE_POST - Support POST requests
  • HTTP_STAGE_PUT - Support PUT requests
  • HTTP_STAGE_TRACE - Support TRACE requests
  • HTTP_STAGE_ALL - Mask to support all methods
moduleOptional module object for loadable stages.
Returns:
A new stage object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
HttpStage * httpCreateHandler (Http *http, cchar *name, int flags, MprModule *module)

Create a request handler stage.

Description:
Create a new handler. Handlers generate outgoing data and are the final stage for incoming data. Their job is to process requests and send outgoing data downstream toward the client consumer. There is ever only one handler for a request.
Parameters:
httpHttp object.
nameName of connector stage.
flagsStage flags mask. These specify what Http request methods will be supported by this stage. Or together any of the following flags:
  • HTTP_STAGE_DELETE - Support DELETE requests
  • HTTP_STAGE_GET - Support GET requests
  • HTTP_STAGE_HEAD - Support HEAD requests
  • HTTP_STAGE_OPTIONS - Support OPTIONS requests
  • HTTP_STAGE_POST - Support POST requests
  • HTTP_STAGE_PUT - Support PUT requests
  • HTTP_STAGE_TRACE - Support TRACE requests
  • HTTP_STAGE_ALL - Mask to support all methods
moduleOptional module object for loadable stages.
Returns:
A new stage object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
HttpStage * httpCreateStage (Http *http, cchar *name, int flags, MprModule *module)

Create a connector stage.

Description:
Create a new stage.
Parameters:
httpHttp object returned from httpCreate
nameName of connector stage.
flagsStage flags mask. These specify what Http request methods will be supported by this stage. Or together any of the following flags:
  • HTTP_STAGE_HANDLER - Stage is a handler DELETE requests
  • HTTP_STAGE_FILTER - Stage is a filter
  • HTTP_STAGE_CONNECTOR - Stage is a connector
  • HTTP_STAGE_GET - Support GET requests
  • HTTP_STAGE_HEAD - Support HEAD requests
  • HTTP_STAGE_OPTIONS - Support OPTIONS requests
  • HTTP_STAGE_POST - Support POST requests
  • HTTP_STAGE_PUT - Support PUT requests
  • HTTP_STAGE_TRACE - Support TRACE requests
  • HTTP_STAGE_ALL - Mask to support all methods
moduleOptional module object for loadable stages.
Returns:
A new stage object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
void httpDefaultOutgoingServiceStage (HttpQueue *q)

Default outgoing data handling.

Description:
This routine provides default handling of outgoing data for stages. It simply sends all packets downstream.
Parameters:
qQueue object.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpLookupStageData, httpSetStageData
void httpHandleOptionsTrace (struct HttpConn *conn)

Handle a Http Trace or Options method request.

Description:
This call responds to a Trace or Options HTTP method request and generates an appropriate response to the client.
Parameters:
connHttpConn object created via $httpCreateConn.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpLookupStage, httpLookupStageData, httpSetStageData
struct HttpStage * HttpStage* httpLookupStage (Http *http, cchar *name)

Lookup a stage by name.

Parameters:
httpHttp object.
nameName of stage to locate.
Returns:
Stage or NULL if not found.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStageData, httpSetStageData
void * httpLookupStageData (Http *http, cchar *name)

Lookup stage data.

Description:
This looks up the stage by name and returns the private stage data.
Parameters:
httpHttp object.
nameName of the stage concerned.
Returns:
Reference to the stage data block.
See Also:
HttpConn, HttpQueue, HttpStage, httpCloneStage, httpCreateConnector, httpCreateFilter, httpCreateHandler, httpCreateStage, httpDefaultOutgoingServiceStage, httpGetStageData, httpHandleOptionsTrace, httpLookupStage, httpSetStageData

HttpTx

HttpTx

Http Tx.

Description:
The tx object controls the transmission of data. This may be client requests or responses to client requests. Most of the APIs in the Response group still take a HttpConn object as their first parameter. This is to make the API easier to remember - APIs take a connection object rather than a rx or transmission object.
API Stability:
Evolving.
See Also:
HttpConn, HttpRx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
Fields:
char *altBody Alternate transmission for errors.
MprOffbytesWritten Bytes written including headers.
HttpCache *cache Cache control entry (only set if this request is being cached).
MprBuf *cacheBuffer Response caching buffer.
ssizecacheBufferLength Current size of the cache buffer data.
cchar *cachedContent Retrieved cached response to send.
ssizechunkSize Chunk size to use when using transfer encoding. Zero for unchunked.
struct HttpConn *conn Current connection object.
HttpStage *connector Network connector to send / receive socket data.
HttpRange *currentRange Current range being fullfilled.
MprOffentityLength Original content length before range subsetting.
char *etag Unique identifier tag.
cchar *ext Filename extension.
MprFile *file File to be served.
MprPathfileInfo File information if there is a real file to serve.
char *filename Name of a real file being served (typically pathInfo mapped).
intflags Response flags.
HttpStage *handler Server-side request handler stage.
MprHash *headers Transmission headers.
ssizeheaderSize Size of the header written.
MprOfflength Transmission content length.
char *method Client request method GET, HEAD, POST, DELETE, OPTIONS, PUT, TRACE.
MprList *outputPipeline Output processing.
HttpRange *outputRanges Data ranges for tx data.
HttpUri *parsedUri Client request uri.
HttpQueue *queue[2] Dummy head for the queues.
char *rangeBoundary Inter-range boundary.
MprOffrangePos Current range I/O position in response data.
intstarted Handler has started.
intstatus HTTP request status.
inttraceMethods Handler methods supported.
void httpAddHeader (HttpConn *conn, cchar *key, cchar *fmt, ...)

Add a header to the transmission using a format string.

Description:
Add a header if it does not already exits.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
fmtPrintf style formatted string to use as the header key value.
...Arguments for fmt.
Returns:
"Zero" if successful, otherwise a negative MPR error code. Returns MPR_ERR_ALREADY_EXISTS if the header already exists.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpAddHeaderString (HttpConn *conn, cchar *key, cchar *value)

Add a header to the transmission.

Description:
Add a header if it does not already exits.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
valueValue to set for the header.
Returns:
Zero if successful, otherwise a negative MPR error code. Returns MPR_ERR_ALREADY_EXISTS if the header already exists.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpAppendHeader (HttpConn *conn, cchar *key, cchar *fmt, ...)

Append a transmission header.

Description:
Set the header if it does not already exists. Append with a ", " separator if the header already exists.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
fmtPrintf style formatted string to use as the header key value.
...Arguments for fmt.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpAppendHeaderString (HttpConn *conn, cchar *key, cchar *value)

Append a transmission header string.

Description:
Set the header if it does not already exists. Append with a ", " separator if the header already exists.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
valueValue to set for the header.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
int httpConnect (HttpConn *conn, cchar *method, cchar *uri)

Connect to a server and issue Http client request.

Description:
Start a new Http request on the http object and return. This routine does not block. After starting the request, you can use httpWait() or httpWForResponse() to wait for the request to achieve a certain state or to complete.
Parameters:
connHttpConn connection object created via $httpCreateConn.
methodHttp method to use. Valid methods include: "GET", "POST", "PUT", "DELETE", "OPTIONS" and "TRACE".
uriURI to fetch.
Returns:
"Zero" if the request was successfully sent to the server. Otherwise a negative MPR error code is returned.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
HttpTx * httpCreateTx (HttpConn *conn, MprHash *headers)
void httpDestroyTx (HttpTx *tx)
void httpFinalize (HttpConn *conn)

Finalize transmission of the http request.

Description:
Finalize writing Http data by writing the final chunk trailer if required. If using chunked transfers, a null chunk trailer is required to signify the end of write data. If the request is already finalized, this call does nothing.
Parameters:
connHttpConn connection object.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpFlush (HttpConn *conn)
void httpFollowRedirects (HttpConn *conn, bool follow)

Follow redirctions.

Description:
Enabling follow redirects enables the Http service to transparently follow 301 and 302 redirections and fetch the redirected URI.
Parameters:
connHttpConn connection object created via $httpCreateConn.
followSet to true to enable transparent redirections.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpFormatError (HttpConn *conn, int status, cchar *fmt, ...)

Format an error transmission.

Description:
Format an error message to use instead of data generated by the request processing pipeline. This is typically used to send errors and redirections. The message is also sent to the error log.
Parameters:
connHttpConn connection object created via $httpCreateConn.
statusHttp response status code.
fmtPrintf style formatted string. This string may contain HTML tags and is not HTML encoded before sending to the user. NOTE: Do not send user input back to the client using this method. Otherwise you open large security holes.
...Arguments for fmt.
Returns:
A count of the number of bytes in the transmission body.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
ssize httpFormatResponse (HttpConn *conn, cchar *fmt, ...)

Format an alternate response.

Description:
Format a response to use instead of data generated by the request processing pipeline. This is used for alternate responses that are not errors.
Parameters:
connHttpConn connection object created via $httpCreateConn.
fmtPrintf style formatted string. This string may contain HTML tags and is not HTML encoded before sending to the user. NOTE: Do not send user input back to the client using this method. Otherwise you open large security holes.
...Arguments for fmt.
Returns:
A count of the number of bytes in the transmission body.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
ssize httpFormatResponseBody (HttpConn *conn, cchar *title, cchar *fmt, ...)

Format a response body.

Description:
Format a transmission body to use instead of data generated by the request processing pipeline. The body will be created in HTML or in plain text depending on the value of the request Accept header. This call is used for alternate responses that are not errors.
Parameters:
connHttpConn connection object created via $httpCreateConn.
titleTitle string to format into the HTML transmission body.
fmtPrintf style formatted string. This string may contain HTML tags and is not HTML encoded before sending to the user. NOTE: Do not send user input back to the client using this method. Otherwise you open large security holes.
...Arguments for fmt.
Returns:
A count of the number of bytes in the transmission body.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpFormatResponseError (HttpConn *conn, int status, cchar *fmt, ...)

Format an error response body.

Description:
Format an error message transmission body to use instead of data generated by the request processing pipeline. The body will be created in HTML or in plain text depending on the value of the request Accept header. This is an internal API and users should use httpError instead.
Parameters:
connHttpConn connection object created via $httpCreateConn.
statusHTTP response status code.
fmtPrintf style formatted string. This string may contain HTML tags and is not HTML encoded before sending to the user. NOTE: Do not send user input back to the client using this method. Otherwise you open large security holes.
...Arguments for fmt.
Returns:
A count of the number of bytes in the transmission body.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
ssize httpFormatResponsev (HttpConn *conn, cchar *fmt, va_list args)

Format an alternate response.

Description:
Format a response to use instead of data generated by the request processing pipeline. This is similar to httpFormatResponse
Parameters:
connHttpConn connection object created via $httpCreateConn.
fmtPrintf style formatted string. This string may contain HTML tags and is not HTML encoded before sending to the user. NOTE: Do not send user input back to the client using this method. Otherwise you open large security holes.
argsVarargs style list of arguments.
Returns:
A count of the number of bytes in the transmission body.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
int httpIsChunked (HttpConn *conn)
int httpIsFinalized (HttpConn *conn)
bool httpNeedRetry (HttpConn *conn, char **url)

Determine if the transmission needs a transparent retry to implement authentication or redirection.

This is used by client requests. If authentication is required, a request must first be tried once to receive some authentication key information that must be resubmitted to gain access
Parameters:
connHttpConn connection object created via $httpCreateConn.
urlReference to a string to receive a redirection URL. Set to NULL if not redirection is required.
Returns:
True if the request needs to be retried.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpRedirect (HttpConn *conn, int status, cchar *uri)
int httpRemoveHeader (HttpConn *conn, cchar *key)
void httpSetContentLength (HttpConn *conn, MprOff length)
void httpSetContentType (HttpConn *conn, cchar *mimeType)
void httpSetCookie (HttpConn *conn, cchar *name, cchar *value, cchar *path, cchar *domain, MprTime lifespan, int flags)

Set a transmission cookie.

Description:
Define a cookie to send in the transmission Http header.
Parameters:
connHttpConn connection object created via $httpCreateConn.
nameCookie name.
valueCookie value.
pathURI path to which the cookie applies.
domainDomain in which the cookie applies. Must have 2-3 dots.
lifespanDuration for the cookie to persist in msec.
flagsSelect from HTTP_COOKIE_SECURE for a "secure" cookie, or HTTP_COOKIE_HTTP for a "httponly" cookie. See RFC 2109 for details about secure and httponly cookies.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpSetHeader (HttpConn *conn, cchar *key, cchar *fmt, ...)

Set a transmission header.

Description:
Set a Http header to send with the request. If the header already exists, it its value is overwritten.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
fmtPrintf style formatted string to use as the header key value.
...Arguments for fmt.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpSetHeaderString (HttpConn *conn, cchar *key, cchar *value)

Set a simple key/value transmission header.

Description:
Set a Http header to send with the request. If the header already exists, it its value is overwritten.
Parameters:
connHttpConn connection object created via $httpCreateConn.
keyHttp response header key.
valueString value for the key.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpSetResponded (HttpConn *conn)

Set the responded flag for the request.

Description:
This call sets the requests responded status. Once status has been defined, headers generated or some output has been generated, the request is regarded as having "responded" in-part to the client.
Parameters:
connHttpConn connection object.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteHeaders, httpWriteUploadData
void httpSetStatus (HttpConn *conn, int status)
void httpSetWriteBlocked (HttpConn *conn)
int httpWait (HttpConn *conn, int state, MprTime timeout)

Wait for the connection to achieve the requested state Used for blocking client requests.

Parameters:
connHttpConn connection object created via $httpCreateConn.
stateHTTP_STATE_XXX to wait for.
timeoutTimeout in milliseconds to wait.
Returns:
"Zero" if successful. Otherwise return a negative MPR error code. Specific returns include: MPR_ERR_TIMEOUT and MPR_ERR_BAD_STATE.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWriteHeaders, httpWriteUploadData
void httpWriteHeaders (HttpConn *conn, HttpPacket *packet)

Write the transmission headers.

Description:
Write the Http transmission headers into the given packet. This should only be called by connectors just prior to sending output to the client. It should be delayed as long as possible if the content length is not yet known to give the pipeline a chance to determine the transmission length. This way, a non-chunked transmission can be sent with a content-length header. This is the fastest HTTP transmission.
Parameters:
connHttpConn connection object created via $httpCreateConn.
packetPacket into which to place the headers.
See Also:
HttpConn, HttpRx, HttpTx, httpAddHeader, httpAddHeaderString, httpAppendHeader, httpAppendHeaderString, httpConnect, httpCreateTx, httpDestroyTx, httpFinalize, httpFlush, httpFollowRedirects, httpFormatError, httpFormatResponse, httpFormatResponseBody, httpFormatResponseError, httpFormatResponsev, httpIsChunked, httpIsFinalized, httpNeedRetry, httpRedirect, httpRemoveHeader, httpSetContentLength, httpSetContentType, httpSetCookie, httpSetHeader, httpSetHeaderString, httpSetResponded, httpSetStatus, httpSetWriteBlocked, httpSetWriteBlocked, httpWait, httpWriteUploadData

HttpUploadFile

HttpUploadFile

Upload File.

Description:
Each uploaded file has an HttpUploadedFile entry. This is managed by the upload handler.
API Stability:
Evolving.
See Also:
httpAddUploadFile, httpRemoveAllUploadedFiles, httpRemoveUploadFile
Fields:
cchar *clientFilename Client side name of the file.
cchar *contentType Content type.
cchar *filename Local (temp) name of the file.
ssizesize Uploaded file size.
void httpAddUploadFile (HttpConn *conn, cchar *id, HttpUploadFile *file)

Add an Uploaded file.

Description:
Add an uploaded file to the Rx.files collection.
Parameters:
connHttpConn connection object created via $httpCreateConn.
idUnique identifier for the file.
fileInstance of HttpUploadFile.
See Also:
httpRemoveAllUploadedFiles, httpRemoveUploadFile
void httpRemoveAllUploadedFiles (HttpConn *conn)

Remove all uploaded files.

Description:
Remove all uploaded files from the temporary file store.
Parameters:
connHttpConn connection object created via $httpCreateConn.
See Also:
httpAddUploadFile, httpRemoveUploadFile
void httpRemoveUploadFile (HttpConn *conn, cchar *id)

Remove an uploaded file.

Description:
Remove an uploaded file from the temporary file store.
Parameters:
connHttpConn connection object created via $httpCreateConn.
idIdentifier used with httpAddUploadFile for the file.
See Also:
httpAddUploadFile, httpRemoveAllUploadedFiles

HttpUri

HttpUri

URI management.

Description:
The HTTP provides routines for formatting and parsing URIs. Routines are also provided to escape dangerous characters for URIs as well as HTML content and shell commands.
API Stability:
Evolving.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
Fields:
char *ext Document extension.
intflags Flags.
char *host Host name.
char *path Uri path (without scheme, host, query or fragements).
intport Port number.
char *query Query string.
char *reference Reference fragment within the specified resource.
char *scheme URI scheme (http|https|...).
intsecure Using https.
char *uri Original URI (not decoded).
HttpUri * httpCloneUri (HttpUri *base, int complete)

Clone a URI.

Description:
This call copies the base URI and optionally completes missing fields in the URI.
Parameters:
baseBase URI to copy.
completeIf set to true, missing fields in the URI will be completed with default values.
Returns:
A new URI object.
See Also:
HttpConn, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpCompleteUri (HttpUri *uri, HttpUri *other)

Complete the given URI.

Description:
Complete the URI supplying missing URI components from the other URI. This modifies the supplied URI and does not allocate or create a new URI.
Parameters:
uriURI to complete.
otherOther URI to supply the missing components.
Returns:
The supplied URI.
See Also:
HttpConn, httpCloneUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpCreateUri (cchar *uri, int complete)

Create and initialize a URI.

Description:
Parse a uri and return a tokenized HttpUri structure.
Parameters:
uriUri string to parse.
completeAdd missing components. ie. Add scheme, host and port if not supplied.
Returns:
A newly allocated HttpUri structure.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpCreateUriFromParts (cchar *scheme, cchar *host, int port, cchar *path, cchar *reference, cchar *query, int complete)

Create a URI from parts.

Description:
This call constructs a URI from the given parts. Various URI parts can be omitted by setting to null. The URI path is the only mandatory parameter.
Parameters:
schemeThe URI scheme. This is typically "http" or "https".
hostThe URI host name portion. This can be a textual host and domain name or it can be an IP address.
portThe URI port number. Set to zero to accept the default value for the selected scheme.
pathThe URI path to the requested document.
referenceURI reference with an HTML document. This is the URI component after the "#" in the URI path.
queryURI query component. This is the URI component after the "?" in the URI.
completeSet to true to complete the URI by supplying missing URI parts with default values.
Returns:
A new URI.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
char * httpFormatUri (cchar *scheme, cchar *host, int port, cchar *path, cchar *ref, cchar *query, int complete)

Format a URI.

Description:
Format a URI string using the input components.
Parameters:
schemeProtocol string for the uri. Example: "http".
hostHost or IP address.
portTCP/IP port number.
pathURL path.
refURL reference fragment.
queryAdditiona query parameters.
completeAdd missing elements. For example, if scheme is null, then add "http".
Returns:
A newly allocated uri string.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpGetRelativeUri (HttpUri *base, HttpUri *target, int clone)

Get a relative URI from the base to the target.

Description:
If the target is null, an absolute URI, or if a relative URI from the base cannot be constructed, then the target will be returned. If clone is true, then a clone of the target will be returned.
Parameters:
baseThe base URI considered to be the current URI. Think of this as the current directory.
targetThe destination URI for which a relative URI will be crafted to reach.
cloneIf true, the target URI will be cloned if the target is an absolute URI or if a relative URI cannot be constructed.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpJoinUri (HttpUri *base, int argc, HttpUri **others)

Join URIs.

Parameters:
baseBase URI to being with.
argcCount of URIs in others.
othersArray of URIs to join to the base.
Returns:
The resulting, joined URI.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpJoinUriPath (HttpUri *result, HttpUri *base, HttpUri *other)

Join a URI path.

Parameters:
resultURI that will be modified with a joined path.
baseURI supplying the base path.
otherOther URI whose path is joined to the base.
Returns:
The result URI.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
cchar * httpLookupMimeType (cchar *ext)

Get the mime type for an extension.

This call will return the mime type from a limited internal set of mime types for the given path or extension
Parameters:
extPath or extension to examine.
Returns:
Mime type. This is a static string.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
HttpUri * httpMakeUriLocal (HttpUri *uri)

Make a URI local.

Description:
This routine removes the scheme, host and port portions of a URI.
Parameters:
uriURI to modify.
Returns:
The given URI.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpNormalizeUriPath, httpResolveUri, httpUriToString
void httpNormalizeUri (HttpUri *uri)

Normalize a URI.

Description:
Validate and canonicalize a URI. This invokes httpNormalizeUriPath to normalize the URI path.
Parameters:
uriURI object to normalize.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri, httpUriToString
char * httpNormalizeUriPath (cchar *uri)

Normalize a URI.

Description:
Validate and canonicalize a URI path. This removes redundant "./" sequences and simplifies "../dir" references.
Parameters:
uriUri path string to normalize. This is the URI path portion without scheme, host and port components.
Returns:
A new validated uri string.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpResolveUri, httpUriToString
HttpUri * httpResolveUri (HttpUri *base, int argc, HttpUri **others, bool local)

Resolve URIs relative to a base.

Parameters:
baseBase URI to begin with.
argcCount of URIs in the others array.
othersArray of URIs that are sucessively resolved relative to the base.
localIf true, the base scheme, host and port are ignored.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpUriToString
char * httpUriToString (HttpUri *uri, int complete)

Convert a Uri to a string.

Description:
Convert the given Uri to a string, optionally completing missing parts such as the host, port and path.
Parameters:
uriA Uri object created via httpCreateUri.
completeFill in missing parts of the uri.
Returns:
A newly allocated uri string.
See Also:
HttpConn, httpCloneUri, httpCompleteUri, httpCreateUri, httpCreateUriFromParts, httpFormatUri, httpGetRelativeUri, httpJoinUri, httpJoinUriPath, httpLookupMimeType, httpMakeUriLocal, httpNormalizeUriPath, httpResolveUri

Functions

struct HttpConn * HttpConn* httpAccept (struct HttpEndpoint *endpoint)

Internal APIs.

HttpConn * httpAcceptConn (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 HttpConn object representing the new connection.
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.
void httpAdjustPacketEnd (HttpPacket *packet, MprOff size)

Adjust the packet end position.

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.
void httpAdjustPacketStart (HttpPacket *packet, MprOff size)

Adjust the packet starting position.

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.
HttpEndpoint * httpCreateConfiguredEndpoint (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. An endpoint is created with a default host and default route.
Parameters:
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.
bool httpFlushQueue (HttpQueue *q, bool block)

Flush queue data.

Description:
This flushes all queue data by scheduling the queue and servicing all scheduled queues. If blocking is requested, the call will block until the queue count falls below the queue maximum. WARNING: Be very careful when using blocking == true. Should only be used by end applications and not by middleware.
Parameters:
qQueue to flush.
blockIf set to "true", this call will block until the data has drained below the queue maximum.
Returns:
"True" if there is room for more data in the queue after flushing.
void * httpGetEndpointContext (HttpEndpoint *endpoint)

Get the endpoint context object.

Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
Returns:
The endpoint context object defined via httpSetEndpointContext.
cchar * 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:
Allocated value string.
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.
char * httpGetPathExt (cchar *path)

Get a path extension.

Parameters:
pathFile pathname to examine.
Returns:
The path extension sans ".".
void * httpGetQueueData (HttpConn *conn)

Get the queue data for the connection.

Parameters:
connHttpConn connection object created via $httpCreateConn.
Returns:
The private queue data object.
int httpIsEndpointAsync (HttpEndpoint *endpoint)

Get if the endpoint is running in asynchronous mode.

Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
Returns:
True if the endpoint is in async mode.
char * httpLink (HttpConn *conn, cchar *target, MprHash *options)

Create a URI link.

Description:
Create a URI link by expansions tokens based on the current request and route state. The target parameter may contain partial or complete URI information. The missing parts are supplied using the current request and route tables. The resulting URI is a normalized, server-local URI (that begins with "/"). The URI will include any defined route prefix, but will not include scheme, host or port components.
Parameters:
connHttpConn connection object.
targetThe URI target. The target parameter can be a URI string or JSON style set of options. The target will have any embedded "{tokens}" expanded by using token values from the request parameters. If the target has an absolute URI path, that path is used directly after tokenization. If the target begins with "~", that character will be replaced with the route prefix. This is a very convenient way to create application top-level relative links.

If the target is a string that begins with "{AT}" it will be interpreted as a controller/action pair of the form "{AT}Controller/action". If the "controller/" portion is absent, the current controller is used. If the action component is missing, the "list" action is used. A bare "{AT}" refers to the "list" action of the current controller.

If the target starts with "{" it is interpreted as being a JSON style set of options that describe the link. If the target is a relative URI path, it is appended to the current request URI path.

If the is a JSON style of options, it can specify the URI components: scheme, host, port, path, reference and query. If these component properties are supplied, these will be combined to create a URI.

If the target specifies either a controller/action or a JSON set of options, The URI will be created according to the route URI template. The template may be explicitly specified via a "route" target property. Otherwise, if an "action" property is specified, the route of the same name will be used. If these don't result in a usable route, the "default" route will be used.

These are the properties supported in a JSON style "{ ... }" target:
  • scheme String URI scheme portion
  • host String URI host portion
  • port Number URI port number
  • path String URI path portion
  • reference String URI path reference. Does not include "#"
  • query String URI query parameters. Does not include "?"
  • controller String Controller name if using a Controller-based route. This can also be specified via the action option.
  • action String Action to invoke. This can be a URI string or a Controller action of the form {AT}Controller/action.
  • route String Route name to use for the URI template
optionsHash of option values for embedded tokens.
Returns:
A normalized, server-local Uri string.
httpLink(conn, "http://example.com/index.html", 0); httpLink(conn, "/path/to/index.html", 0); httpLink(conn, "../images/splash.png", 0); httpLink(conn, "~/static/images/splash.png", 0); httpLink(conn, "${app}/static/images/splash.png", 0); httpLink(conn, "@controller/checkout", 0); httpLink(conn, "@controller/") // Controller = Controller, action = index httpLink(conn, "@init") // Current controller, action = init httpLink(conn, "@") // Current controller, action = index httpLink(conn, "{ action: '@post/create' }", 0); httpLink(conn, "{ action: 'checkout' }", 0); httpLink(conn, "{ action: 'logout', controller: 'admin' }", 0); httpLink(conn, "{ action: 'admin/logout'", 0); httpLink(conn, "{ product: 'candy', quantity: '10', template: '/cart/${product}/${quantity}' }", 0); httpLink(conn, "{ route: '~/STAR/edit', action: 'checkout', id: '99' }", 0); httpLink(conn, "{ template: '~/static/images/${theme}/background.jpg', theme: 'blue' }", 0);
struct HttpEndpoint * HttpEndpoint* httpLookupEndpoint (Http *http, cchar *ip, int port)

Lookup a listening endpoint.

Parameters:
httpHttp object created via httpCreate
ipListening IP address to look for.
portListening port number.
Returns:
HttpEndpoint object.
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.
HttpRoute * httpLookupRoute (HttpHost *host, cchar *name)

Lookup a route by name.

Parameters:
hostHttpHost object owning the route table.
nameRoute name to find. If null or empty, look for "default".
void httpMapFile (HttpConn *conn, HttpRoute *route)

Map the request URI and route target to a filename.

Description:
This sets the HttpTx filename, ext, etag and info fields.
Parameters:
connHttpConn connection object.
routeRoute to modify.
void httpOmitBody (HttpConn *conn)

Tell the tx to omit sending any body.

Parameters:
connHttpConn connection object created via $httpCreateConn.
int httpOpenQueue (HttpQueue *q, ssize chunkSize)

Open the queue.

Call the queue open entry point
Parameters:
qQueue reference.
chunkSizePreferred chunk size.
Returns:
"Zero" if successful.
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.
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.
bool httpServiceQueues (HttpConn *conn)

Service pipeline queues to flow data.

Parameters:
connHttpConn object created via $httpCreateConn.
void httpSetContext (Http *http, void *context)

Set the http context object.

Parameters:
httpHttp object created via httpCreate
contextNew context object.
void httpSetEndpointAsync (HttpEndpoint *endpoint, int enable)

Control if the endpoint is running in asynchronous mode.

Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
enableSet to 1 to enable async mode.
void httpSetEndpointContext (HttpEndpoint *endpoint, void *context)

Set the endpoint context object.

Parameters:
endpointHttpEndpoint object created via httpCreateEndpoint
contextNew context object.
void httpSetEntityLength (HttpConn *conn, MprOff len)

Define the length of the transmission content.

When static content is used for the transmission body, defining the entity length permits the request pipeline to know when all the data has been sent
Parameters:
connHttpConn connection object created via $httpCreateConn.
lenTransmission body length in bytes.
void httpSetSoftware (Http *http, cchar *description)

Set the software description.

Parameters:
httpHttp object created via httpCreate
descriptionString describing the Http software. By default, this is set to HTTP_NAME.
bool httpVerifyQueue (HttpQueue *q)

Verify a queue.

Parameters:
qQueue reference.
Returns:
"True" if the queue verifies.

Typedefs

typedef long HttpAcl.

Authentication Access control mask.

typedef int(* HttpHeadersCallback)(void *arg).

Callback to fill headers.

Description:
If defined, the headers callback will run before the standard response headers are generated. This gives an opportunity to pre-populate the response headers.
Parameters:
argArgument provided to httpSetHeadersCallback when the callback was established.
typedef int( HttpRouteProc)(HttpConn *conn, HttpRoute *route, HttpRouteOp *item).

General route procedure.

Used by targets, conditions and updates
typedef cchar*(* HttpGetPassword)(struct HttpAuth *auth, cchar *realm, cchar *user).
typedef bool(* HttpValidateCred)(struct HttpAuth *auth, cchar *realm, char *user, cchar *pass, cchar *required, char **msg).

Validate user credentials callback.

Parameters:
authHttpAuth object.
realmHttp authentication realm.
userUser name for whom to retrieve the password.
passUser password.
requiredAuthentication "required" field. Set to "user", "group" or "valid".
msgOutput parameter to contain any appropriate error message.
Returns:
True if the user credentials can be validated and accepted.
See Also:
HttpAuth, HttpGetPassword, HttpGroup, HttpUser, httpAddGroup, httpAddUser, httpAddUserToGroup, httpAddUsersToGroup, httpCreateAuth, httpCreateGroup, httpCreateUser, httpDisableGroup, httpDisableUser, httpEnableGroup, httpEnableUser, httpGetFilePassword, httpGetGroupAcl, httpIsGroupEnabled, httpIsUserEnabled, httpParseAcl, httpReadGroupFile, httpReadUserFile, httpRemoveGroup, httpRemoveUser, httpRemoveUserFromGroup, httpRemoveUsersFromGroup, httpSetAuthAnyValidUser, httpSetAuthDeny, httpSetAuthOrder, httpSetAuthQop, httpSetAuthRealm, httpSetAuthRequiredGroups, httpSetAuthRequiredUsers, httpSetAuthUser, httpSetGroupAcl, httpSetRequiredAcl, httpUpdateUserAcls, httpValidateFileCredentials, httpWriteGroupFile, httpWriteUserFile
typedef void(* HttpEnvCallback)(struct HttpConn *conn).
typedef void(* HttpIOCallback)(struct HttpConn *conn, MprEvent *event).
typedef int(* HttpListenCallback)(struct HttpEndpoint *endpoint).
typedef void(* HttpNotifier)(struct HttpConn *conn, int state, int flags).
typedef cchar*(* HttpRedirectCallback)(struct HttpConn *conn, int *code, struct HttpUri *uri).
typedef ssize(* HttpFillProc)(struct HttpQueue *q, struct HttpPacket *packet, MprOff pos, ssize size).

Callback procedure to fill a packet with data.

Parameters:
qQueue owning the packet.
packetThe packet to fill.
offOffset in the packet to fill with data.
sizeSize of packet from the offset to fill.
Returns:
The number of bytes copied into the packet.
See Also:
HttpPacket, HttpQueue, httpClonePacket, httpCreateDataPacket, httpCreateEndPacket, httpCreateEntityPacket, httpCreateHeaderPacket, httpCreatePacket, httpGetPacket, httpGetPacketLength, httpJoinPacket, httpPutBackPacket, httpPutForService, httpPutPacket, httpPutPacketToNext, httpSplitPacket
HttpGroup

Group Authorization.

API Stability:
Evolving.
Fields:
HttpAclacl Group access control list.
boolenabled Group is enabled.
char *name Group name.
MprList *users List of users.
See Also:
HttpAuth
HttpLang

Language definition record for routes.

Fields:
intflags Control suffix position.
char *path Document directory for the language.
char *suffix Suffix to add to filenames.
HttpRouteOp

Route operation record.

Fields:
char *details General route operation details.
void *mdata pcre_ data managed by malloc().
char *name Name of route operation.
char *value Value to assign to var.
char *var Var to set.
HttpUser

User Authorization File-based authorization backend.

API Stability:
Evolving.
Fields:
HttpAclacl Access control list. Union (or) of all group Acls.
boolenabled User is enabled.
char *name User name.
char *password User password.
char *realm Authentication realm.
See Also:
HttpAuth
Generated on Mon Nov 21 2012 10:44:42 GMT-0800 (PST)
Copyright © Embedthis Software 2012.