Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

http.c File Reference

PDepp's http parser. More...

#include "common.h"
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "logger.h"
#include "http.h"
#include "buffer.h"
#include "bufplist.h"
#include "conftable.h"
#include "conn_handler.h"
#include "misc.h"
#include "reqhandler_file.h"
#include "xmalloc.h"

Include dependency graph for http.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  HttpProtHandler
 the struct containing all necessary information (on http-level) for a connection. More...

struct  HttpRequestHdr
 the struct containing the request information. More...

struct  Uri
 struct to contain a whole URI. More...


Defines

#define MKHTTPRESPONSE_TIME_BUF_LEN   30
 the length of our time representation string incl '\0' (ie. "Thu, 20 Dec 2001 10:18:31 GMT").


Enumerations

enum  Method { MUNKNOWN, GET, HEAD, POST }
 the request method.

enum  HttpVer { VUNKNOWN, V09, V10, V11 }
 the http version.

enum  Encoding { EUNKNOWN, IDENTITY, GZIP, COMPRESS }
 the encoding type.

enum  Connection { CUNKNOWN, CLOSE, KEEPALIVE }
 the connection kind.


Functions

int htRecvLine (HttpProtHandler this, const char *str)
  receive a line of data.

int copyRequestLine (HttpProtHandler this, struct Buffer *buf)
int htMthdParse (HttpProtHandler this, const char *str)
  parses the first line of the http header.

int htAddData (struct HttpRequestHdr *hdr, const char *str)
  parse header fields into hdr.

Uri resolvURI (const char *str)
  converts the URI string to struct URI.

const char * getStatusAsText (HttpProtHandler this)
  return a verbose description for a http status code.

int buildBasicHeader (HttpProtHandler this)
 builds the standard headerfields. More...

int buildEntityHeader (HttpProtHandler this)
 builds the three entity header lines used for files. More...

int appendHdrField (BufpList hdr_list, char *prefix, char *data)
  add a field. More...

int err2Status (int err)
 convert errorcode to http-status.

int htModulePreInit ()
 pre-initialise module.

int htModuleTerminate ()
 clean up rssources allocated by module.

HttpProtHandler htInit (ConnHandler parent)
 creates, initializes and returns a Http Protokoll Handler. More...

int htReceive (HttpProtHandler this, struct Buffer buf)
 orders a ProtHandler to Recieve data. More...

int htSend (HttpProtHandler this, struct Buffer **buf)
 orders a ProtHandler to send buffered data. More...

int htProcess (HttpProtHandler this)
 gives the chance to do some internal job. More...

int htIsDataPending (HttpProtHandler this)
 checks if data is pending. More...

int htTerminate (HttpProtHandler this)
 terminates this. More...

int htGetError (HttpProtHandler this)
 returns the error of this. More...

char * timetToStr (time_t t, struct Buffer *time_buf)
  convert a time_t to a string (reentrant).

time_t strToTimet (const char *str)
  convert an rfc1123 or rfc850 conformant textual time representation to an time_t.


Variables

int reply_server_name
 boolean: if the server should indentify itself in each reply.


Detailed Description

PDepp's http parser.

Definition in file http.c.


Function Documentation

int appendHdrField BufpList    hdr_list,
char *    prefix,
char *    data
 

add a field.

Todo:
use a variadic arguments function

Definition at line 679 of file http.c.

Referenced by buildEntityHeader(), and htRecvLine().

int buildBasicHeader HttpProtHandler    this
 

builds the standard headerfields.

Parameters:
this  the Http protocol handler to be manipulated
the headerfields are stored in this->hdr_list

Returns:
0 on success, -1 otherwise

Definition at line 598 of file http.c.

Referenced by htRecvLine().

int buildEntityHeader HttpProtHandler    this
 

builds the three entity header lines used for files.

Parameters:
this  the Http protocol handler to be manipulated
Returns:
0 on success, -1 otherwise

Definition at line 649 of file http.c.

Referenced by htRecvLine().

int copyRequestLine HttpProtHandler    this,
struct Buffer   buf
 

copies a logical line from the connection handlers receive buffer to its line buffer as a single null terminated string line breaks are replaced by spaces

Returns:
0 on success (line copied), -1 if end of recv buffer but no logical "end of line" encountered

Definition at line 474 of file http.c.

Referenced by htReceive().

int htGetError HttpProtHandler    this
 

returns the error of this.

Parameters:
this  the struct to be manipulated
Returns:
error of this

Definition at line 292 of file http.c.

HttpProtHandler htInit ConnHandler    parent
 

creates, initializes and returns a Http Protokoll Handler.

Parameters:
parent  Parent ie. caller
htInit just initialises some std. values and resets data

Returns:
an initialized HttpProtHandler

Definition at line 165 of file http.c.

int htIsDataPending HttpProtHandler    this
 

checks if data is pending.

Parameters:
this  the struct containing data information
Returns:
true if data pending, else false

Definition at line 251 of file http.c.

int htProcess HttpProtHandler    this
 

gives the chance to do some internal job.

Parameters:
this  the struct containing data information
gives this the chance to do some internal work. NOTHING IMPLEMENTED NOW

Returns:
0 on success, -1 on error (error of this is set to apropriate error)

Definition at line 240 of file http.c.

int htReceive HttpProtHandler    this,
struct Buffer    buf
 

orders a ProtHandler to Recieve data.

Parameters:
this  the struct to be manipulated
str  the string containing the data to be recieved
htRecieve has to be understood as htRecieve!, because it is a call to do so. The data to be recieved is a buffer, which will be processed and validated.

Returns:
0 on success, -1 if any error occured (error of this is set to concrete error)

Definition at line 182 of file http.c.

int htSend HttpProtHandler    this,
struct Buffer **    buf
 

orders a ProtHandler to send buffered data.

Parameters:
this  the struct containing data information
buf  the buffer (pnter), in which the data will be stored
htSend has to be understood as htSend!, because it is a call to do so. If data is waiting, it will be stored in buf, else (*buf)->data is set to NULL.

Returns:
0 on success, -1 on error (error of this is set to concrete error)

Definition at line 208 of file http.c.

int htTerminate HttpProtHandler    this
 

terminates this.

Parameters:
this  the struct to be terminated
terminates this and frees all allocated memory used by this. Also calls underlying terminate functions

Returns:
0 on success, -1 on error (error of this is set to apropriate error)

Definition at line 259 of file http.c.


Generated on Fri Jan 25 22:40:47 2002 for PDepp Webserver by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001