Nut/OS  5.0.5
API Reference
Redirection
Collaboration diagram for Redirection:

Data Structures

struct  _HTTP_LOCATION
 HTTP redirection information structure. More...

Typedefs

typedef struct _HTTP_LOCATION HTTP_LOCATION
 HTTP redirection entry type.

Functions

int HttpRegisterRedir (const char *url, const char *redir, int response)
 Register an HTTP redirection.
int HttpLocationRedir (HTTPD_SESSION *hs)
 Default HTTP redirection handler.
HTTP_LOCATIONHttpLocationLookup (const char *uri)
 Retrieve redirection entry for a given resource.

Detailed Description

$Id$


Typedef Documentation

typedef struct _HTTP_LOCATION HTTP_LOCATION

HTTP redirection entry type.


Function Documentation

int HttpRegisterRedir ( const char *  url,
const char *  redir,
int  response 
)

Register an HTTP redirection.

The following sample permanently redirects an empty resource to the index page index.html.

 #include <pro/uhttp/modules/mod_redir.h>

 HttpRegisterRedir("", "/index.html", 301);

This function will automatically set the default redirection handler HttpLocationRedir().

Parameters:
urlThe resource that will be redirected.
redirThe redirection target.
responseThe HTTP response code that will be send with the redirection.
Returns:
0 if the redirection has been successfully registered. Otherwise -1 is returned.

References calloc, free(), httpd_loc_redirector, HttpLocationRedir(), ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_INSERTBEFORE, ISC_LIST_NEXT, _HTTP_LOCATION::loc_redir, _HTTP_LOCATION::loc_response, _HTTP_LOCATION::loc_uri, rc, strcasecmp, and strdup().

Here is the call graph for this function:

int HttpLocationRedir ( HTTPD_SESSION hs)

Default HTTP redirection handler.

This function is automatically called by the default client handler function HttpdClientHandler() after at least one redirection entry had been registered.

Parameters:
hsPointer to the session info structure.
Returns:
0 if a redirection response had been sent. -1 is returned if no redirection exists, in which case the caller should handle the original request.

References HTTP_ASSERT, HttpLocationLookup(), HttpSendRedirection(), _HTTP_LOCATION::loc_redir, _HTTP_LOCATION::loc_response, NULL, _HTTP_REQUEST::req_url, and _HTTPD_SESSION::s_req.

Referenced by HttpRegisterRedir().

Here is the call graph for this function:

HTTP_LOCATION* HttpLocationLookup ( const char *  uri)

Retrieve redirection entry for a given resource.

This routine may be used by custom redirection handlers.

Referenced by HttpLocationRedir().