The following status codes are interpreted by the errorpage() routine. Look at the documentation of the status codes for more details about their meaning.
print a message related to a connection to a stream.
Detailed Description
misc routines for the http server
This module contains some routines that might be useful for implementing the webserver.
Define Documentation
#define EBADREQUEST 400
Bad Request
#define EERROR 500
Internal server error
#define EFORBIDDEN 403
Forbidden
#define ENOTFOUND 404
Not found
Function Documentation
void badreq
(
FILE *
client,
const char *
relPath,
uint16_t
port
)
Output a bad request html page to a stream.
This routine generates a bad request (400) error page on the given stream, which should normally be the client connection.
Parameters:
client
the output stream
relPath
requested URL
port
Port number the webserver accepts connections on
See also:
errorpage Generic function for error page generation
int checkpath
(
const char *
relPath
)
checks if a relative path leaves the root dir
This routine checks if the relative path component of a request ascends the VFS beyond the root directory. Such requests should not be served.
Note that this function stops processing as soon as the path ascends beyond the root of the web directory.
Parameters:
relPath
requested URL
Returns:
positive depth of the request relative to the web directory, or -1 if the relative URL ascends beyond the web directory.
void errorpage
(
FILE *
client,
int
statusCode,
const char *
fullPath,
const char *
relPath,
uint16_t
port
)
Generic routine for error html page generation.
This routine generates an error page on the given stream, which should normally be the client connection.
Parameters:
client
the output stream
statusCode
which error page to output
fullPath
full local path of the requested file
relPath
requested URL
port
Port number the webserver accepts connections on
void forbidden
(
FILE *
client,
const char *
fullPath,
const char *
relPath,
uint16_t
port
)
Output a forbidden html page to a stream.
This routine generates a forbidden (403) error page on the given stream, which should normally be the client connection.
Parameters:
client
the output stream
fullPath
full local path of the requested file
relPath
requested URL
port
Port number the webserver accepts connections on
See also:
errorpage Generic function for error page generation
void internalServerError
(
FILE *
client,
const char *
fullPath,
const char *
relPath,
uint16_t
port
)
Output a internal server error html page to a stream.
This routine generates a internal server (500) error page on the given stream, which should normally be the client connection.
Parameters:
client
the output stream
fullPath
full local path of the requested file
relPath
requested URL
port
Port number the webserver accepts connections on
See also:
errorpage Generic function for error page generation
void notfound
(
FILE *
client,
const char *
fullPath,
const char *
relPath,
uint16_t
port
)
Output a not found html page to a stream.
This routine generates a not found (404) error page on the given stream, which should normally be the client connection.
Parameters:
client
the output stream
fullPath
full local path of the requested file
relPath
requested URL
port
Port number the webserver accepts connections on
See also:
errorpage Generic function for error page generation
void printconn
(
FILE *
stream,
FILE *
peer,
const char *
msg
)
print a message related to a connection to a stream.
This routine prints a message that is related to a connection to a stream. The message will contain the hostname of the peer or its IP address if the hostname lookup fails.