|
|
 |
|
|
 |
Collaboration diagram for HTTP:
Detailed Description
Hypertext transfer protocol.
|
Data Structures |
| struct | _REQUEST |
| | HTTP request information structure. More...
|
| struct | _AUTHINFO |
| | HTTP authorization information structure. More...
|
| struct | _CGIFUNCTION |
| | Registered CGI function. More...
|
| struct | _REQUEST |
| | HTTP request information structure. More...
|
| struct | _AUTHINFO |
| | HTTP authorization information structure. More...
|
| struct | _CGIFUNCTION |
| | Registered CGI function. More...
|
Defines |
|
#define | METHOD_GET |
|
#define | METHOD_POST |
|
#define | METHOD_HEAD |
Typedefs |
|
typedef _REQUEST | REQUEST |
|
typedef _AUTHINFO | AUTHINFO |
|
typedef _CGIFUNCTION | CGIFUNCTION |
Functions |
| void | NutHttpProcessRequest (FILE *stream) |
| | Process the next HTTP request.
|
| void | NutHttpSendHeaderTop (FILE *stream, REQUEST *req, int status, char *title) |
| | Send top lines of a standard HTML header.
|
| void | NutHttpSendHeaderBot (FILE *stream, char *mime_type, long bytes) |
| | Send bottom lines of a standard HTML header.
|
| void | NutHttpSendError (FILE *stream, REQUEST *req, int status) |
| | Send a HTTP error response.
|
| char * | NutGetMimeType (char *name) |
| | Return the mime type description of a specified file name.
|
| int | NutHttpAuthValidate (REQUEST *req) |
| | Validate an authorization request.
|
| int | NutRegisterAuth (CONST char *dirname, CONST char *login) |
| | Register an authorization entry.
|
| int | NutRegisterCgi (char *name, int(*func)(FILE *, REQUEST *)) |
| | Register a CGI function.
|
| void | NutCgiProcessRequest (FILE *stream, REQUEST *req) |
| | Process an incoming CGI request.
|
|
char * | NutHttpURLEncode (char *str) |
| void | NutHttpURLDecode (char *str) |
| | URLDecodes a string.
|
| char * | NutHttpGetParameter (REQUEST *req, char *name) |
| | Gets a request parameter value by name.
|
| int | NutHttpGetParameterCount (REQUEST *req) |
| | Gets the number of request parameters.
|
| char * | NutHttpGetParameterName (REQUEST *req, int index) |
| | Gets the name of a request parameter.
|
| char * | NutHttpGetParameterValue (REQUEST *req, int index) |
| | Get the value of a request paramter.
|
| int | NutRegisterHttpRoot (char *path) |
| | Register the HTTP server's root directory.
|
Variables |
|
AUTHINFO * | authList |
|
CGIFUNCTION *volatile | cgiFunctionList |
Function Documentation
| void NutCgiProcessRequest |
( |
FILE * |
stream, |
|
|
REQUEST * |
req |
|
) |
|
|
|
|
Process an incoming CGI request.
Applications do not need to call this function. It is automatically called by NutHttpProcessRequest().
- Parameters:
-
| stream | Stream of the socket connection, previously opened for binary read and write. |
| req | Contains the HTTP request. |
|
| char * NutGetMimeType |
( |
char * |
name |
) |
|
|
|
|
Return the mime type description of a specified file name.
The mime type returned is based on the file extension.
- Parameters:
-
- Returns:
- A pointer to a static string, containing the associated mime type description. If the extension is not registered, "text/plain; charset=iso-8859-1" is returned. If the filename is empty, then "text/hatml; charset=iso-8859-1" is returned.
|
| int NutHttpAuthValidate |
( |
REQUEST * |
req |
) |
|
|
|
|
Validate an authorization request.
- Note:
- This function is automatically called by the HTTP library on incoming requests. Applications do not need to call this function.
- Parameters:
-
| req | Request to be checked. |
- Returns:
- 0, if access granted, -1 otherwise.
|
| char* NutHttpGetParameter |
( |
REQUEST * |
req, |
|
|
char * |
name |
|
) |
|
|
|
|
Gets a request parameter value by name.
- Parameters:
-
| req | Request object |
| name | Name of parameter |
- Returns:
- Pointer to the parameter value.
|
| int NutHttpGetParameterCount |
( |
REQUEST * |
req |
) |
|
|
|
|
Gets the number of request parameters.
- Parameters:
-
- Returns:
- The number of request parameters
|
| char* NutHttpGetParameterName |
( |
REQUEST * |
req, |
|
|
int |
index |
|
) |
|
|
|
|
Gets the name of a request parameter.
- Parameters:
-
| req | Request object |
| index | Index of the requested parameter. |
- Returns:
- Pointer to the parameter name at the given index, or NULL if index is out of range.
|
| char* NutHttpGetParameterValue |
( |
REQUEST * |
req, |
|
|
int |
index |
|
) |
|
|
|
|
Get the value of a request paramter.
- Parameters:
-
| req | Request object |
| index | Index to the requested parameter. |
- Returns:
- Pointer to the paramter value at the given index, or NULL if index is out of range.
|
| void NutHttpProcessRequest |
( |
FILE * |
stream |
) |
|
|
|
|
Process the next HTTP request.
Waits for the next HTTP request on an established connection and processes it.
- Parameters:
-
| stream | Stream of the socket connection, previously opened for binary read and write. |
- Examples:
-
httpd/httpserv.c.
|
| void NutHttpSendError |
( |
FILE * |
stream, |
|
|
REQUEST * |
req, |
|
|
int |
status |
|
) |
|
|
|
|
Send a HTTP error response.
A canned error file is used.
- Parameters:
-
| stream | Stream of the socket connection, previously opened for binary read and write. |
| req | Contains the HTTP request. |
| status | Error code to be returned. |
|
| void NutHttpSendHeaderBot |
( |
FILE * |
stream, |
|
|
char * |
mime_type, |
|
|
long |
bytes |
|
) |
|
|
|
|
Send bottom lines of a standard HTML header.
Sends Content-Type, Content-Lenght and Connection lines.
- Parameters:
-
| stream | Stream of the socket connection, previously opened for binary read and write. |
| mime_type | Points to a string that specifies the content type. Examples are "text/html", "image/png", "image/gif", "video/mpeg" or "text/css". A null pointer is ignored. |
| bytes | Content length of the data following this header. Ignored, if negative. |
- Examples:
-
httpd/httpserv.c.
|
| void NutHttpSendHeaderTop |
( |
FILE * |
stream, |
|
|
REQUEST * |
req, |
|
|
int |
status, |
|
|
char * |
title |
|
) |
|
|
|
|
Send top lines of a standard HTML header.
Sends HTTP and Server version lines.
- Parameters:
-
| stream | Stream of the socket connection, previously opened for binary read and write. |
| req | The associated client request. |
| status | Response status, error code or 200, if no error occured. |
| title | Error text, or OK, if no error occured. |
- Examples:
-
httpd/httpserv.c.
|
| void NutHttpURLDecode |
( |
char * |
str |
) |
|
|
|
|
URLDecodes a string.
Takes a url-encoded string and decodes it.
- Parameters:
-
| str | String to decode. This is overwritten with the decoded string |
- Warning:
- To save RAM, the str parameter will be overwritten with the encoded string.
|
| int NutRegisterAuth |
( |
CONST char * |
dirname, |
|
|
CONST char * |
login |
|
) |
|
|
|
|
Register an authorization entry.
Protect a specified directory from unauthorized access.
- Warning:
- Directories not registered by this function are accessible by anyone.
- Parameters:
-
| dirname | Name of the directory to protect. |
| login | Required login to access this directory. This string must contain a user name, followed by a colon followed by an uncrypted password. |
- Returns:
- 0 on success, -1 otherwise.
- Examples:
-
httpd/httpserv.c.
|
| int NutRegisterCgi |
( |
char * |
name, |
|
|
int(*)(FILE *, REQUEST *) |
func |
|
) |
|
|
|
|
Register a CGI function.
- Parameters:
-
| name | Name of this CGI function. |
| func | The function to be called, if the client requests the specified name. |
- Returns:
- 0 on success, -1 otherwise.
|
| int NutRegisterHttpRoot |
( |
char * |
path |
) |
|
|
|
|
Register the HTTP server's root directory.
Only one root directory is supported. Subsequent calls will override previous settings.
- Parameters:
-
| path | Pathname of the root directory. Must include the device name followed by a colon followed by a directory path followed by a trailing slash. |
- Returns:
- 0 on success, -1 otherwise.
|
|
 |
|