Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
SP
 
  Vorlesung
  Folien
  Übungen
  Evaluation
  Prüfungsinformationen
  Forum
  protected area Intern
Übungen
  Folien
  Aufgaben
Department Informatik  >  Informatik 4  >  Lehre  >  WS 2010/11  >  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.

Functions

void badreq (FILE *client, const char *relPath, uint16_t port)
 Output a bad request 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.
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.


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

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 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

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-01-24 10:23   MS