Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
SP
 
  SP1
  SP2
Übungen
  Anmeldung
  Folien
  Aufgaben
Department Informatik  >  Informatik 4  >  Lehre  >  SS 2011  >  SP  >  Übung  >  Doku  >  multithreaded webserver: i4httools.h File Reference

process list

i4httools.h File Reference

misc routines for the http server More...

#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>

Go to the source code of this file.

Defines

Status codes

The following status codes are interpreted by the errorpage() routine. Look at the documentation of the status codes for more details about their meaning.

#define EBADREQUEST   400
#define EFORBIDDEN   403
#define ENOTFOUND   404
#define EERROR   500

Functions

void badreq (FILE *client, const char *relPath, uint16_t port)
 Output a bad request html page to a stream.
void forbidden (FILE *client, const char *fullPath, const char *relPath, uint16_t port)
 Output a forbidden html page to a stream.
void notfound (FILE *client, const char *fullPath, const char *relPath, uint16_t port)
 Output a not found html page to a stream.
void internalServerError (FILE *client, const char *fullPath, const char *relPath, uint16_t port)
 Output a internal server error html page to a stream.
void errorpage (FILE *client, int statusCode, const char *fullPath, const char *relPath, uint16_t port)
 Generic routine for error html page generation.
int checkpath (const char *relPath)
 checks if a relative path leaves the root dir
void printconn (FILE *stream, FILE *peer, const char *msg)
 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.

Parameters:
stream output stream
peer connection to the peer
msg custom message to output
  Impressum   Datenschutz Stand: 2011-07-04 18:03   MS