Miscellaneous routines for building an HTTP server. More...
#include <stdio.h>Go to the source code of this file.
Functions | |
| int | checkPath (const char relPath[]) |
| Checks if a relative path leaves the root directory. | |
| void | httpOK (FILE *client) |
| Outputs an "OK" HTTP response to a stream. | |
| void | httpMovedPermanently (FILE *client, const char newRelPath[]) |
| Outputs a "moved permanently" HTTP response and error page to a stream. | |
| void | httpBadRequest (FILE *client, const char request[]) |
| Outputs a "bad request" HTTP response and error page to a stream. | |
| void | httpForbidden (FILE *client, const char fullPath[], const char relPath[]) |
| Outputs a "forbidden" HTTP response and error page to a stream. | |
| void | httpNotFound (FILE *client, const char fullPath[], const char relPath[]) |
| Outputs a "not found" HTTP response and error page to a stream. | |
| void | httpInternalServerError (FILE *client, const char fullPath[], const char relPath[]) |
| Outputs an "internal server error" HTTP response and error page to a stream. | |
Miscellaneous routines for building an HTTP server.
This module contains some routines that are useful for implementing a web server.
| int checkPath | ( | const char | relPath[] | ) |
Checks if a relative path leaves the root directory.
This routine checks if the relative path component of a request ascends the VFS beyond the root directory. Such requests should not be served.
| relPath | Requested URL. |
| void httpBadRequest | ( | FILE * | client, | |
| const char | request[] | |||
| ) |
Outputs a "bad request" HTTP response and error page to a stream.
This routine generates an "HTTP/1.0 400 Bad Request" status line and a corresponding HTML error page on the given stream, which should normally be the client connection.
| client | The output stream. | |
| request | Request string. |
| void httpForbidden | ( | FILE * | client, | |
| const char | fullPath[], | |||
| const char | relPath[] | |||
| ) |
Outputs a "forbidden" HTTP response and error page to a stream.
This routine generates an "HTTP/1.0 403 Forbidden" status line and a corresponding HTML error page on the given stream, which should normally be the client connection.
| client | The output stream. | |
| fullPath | Full local path of the requested file. | |
| relPath | Requested URL. |
| void httpInternalServerError | ( | FILE * | client, | |
| const char | fullPath[], | |||
| const char | relPath[] | |||
| ) |
Outputs an "internal server error" HTTP response and error page to a stream.
This routine generates an "HTTP/1.0 500 Internal Server Error" status line and a corresponding HTML error page on the given stream, which should normally be the client connection.
| client | The output stream. | |
| fullPath | Full local path of the requested file. | |
| relPath | Requested URL. |
| void httpMovedPermanently | ( | FILE * | client, | |
| const char | newRelPath[] | |||
| ) |
Outputs a "moved permanently" HTTP response and error page to a stream.
This routine generates a "moved permanently (301)" HTTP response on the given stream, which should normally be the client connection.
| client | The output stream. | |
| newRelPath | Path to which the request is redirected. |
| void httpNotFound | ( | FILE * | client, | |
| const char | fullPath[], | |||
| const char | relPath[] | |||
| ) |
Outputs a "not found" HTTP response and error page to a stream.
This routine generates an "HTTP/1.0 404 Not Found" status line and a corresponding HTML error page on the given stream, which should normally be the client connection.
| client | The output stream. | |
| fullPath | Full local path of the requested file. | |
| relPath | Requested URL. |
| void httpOK | ( | FILE * | client | ) |
Outputs an "OK" HTTP response to a stream.
This routine generates an "OK (200)" status line on the given stream, which should normally be the client connection.
| client | The output stream. |
1.7.1