/*+********************************************************************** * File name : httpd.h * Title : Main Header file for httpd * Project : SW INFRASTRUCTURE * Date created : 15 OCT 1997 * Revision : Rev 1.0 * Author : Nir Ben-Yosef * * *-*********************************************************************/ #ifndef _HTTPD_H #define _HTTPD_H #include "http_util.h" #define HTTPD_TASK_PRIORITY 100 #define HTTPD_STACK_SIZE 4096*8 #define HTTPD_CHILD_STACK_SIZE 8192*4 #define HTTPD_SOCKET_TIMEOUT 10 /* Seconds */ #define HTTPD_SEM_TIMEOUT 10 /* Time Ticks */ #define DEFAULT_PORT 80 #define HTTP_DEFAULT_PORT 80 /* The default string lengths */ #define MAX_STRING_LEN HUGE_STRING_LEN #define HUGE_STRING_LEN 2048 #define LITTLE_STRING_LEN 128 #define VERY_LITTLE_STRING_LEN 16 /* The timeout for waiting for messages */ #define DEFAULT_TIMEOUT 300 /* The timeout for waiting for keepalive timeout until next request */ #define DEFAULT_KEEPALIVE_TIMEOUT 15 /* The number of requests to entertain per connection */ #define DEFAULT_KEEPALIVE 100 /* The number of concurrent Http Tasks */ #define MAX_SESSIONS 2 #define SERVER_PROTOCOL "HTTP/1.1" #define SERVER_VERSION "PPP PROXY 1.0" #define OK 0 /* Module has handled this stage. */ /* ----------------------- HTTP Status Codes ------------------------- */ #define HTTP_CONTINUE 100 #define HTTP_SWITCHING_PROTOCOLS 101 #define HTTP_OK 200 #define HTTP_CREATED 201 #define HTTP_ACCEPTED 202 #define HTTP_NON_AUTHORITATIVE 203 #define HTTP_NO_CONTENT 204 #define HTTP_RESET_CONTENT 205 #define HTTP_PARTIAL_CONTENT 206 #define HTTP_MULTIPLE_CHOICES 300 #define HTTP_MOVED_PERMANENTLY 301 #define HTTP_MOVED_TEMPORARILY 302 #define HTTP_SEE_OTHER 303 #define HTTP_NOT_MODIFIED 304 #define HTTP_USE_PROXY 305 #define HTTP_BAD_REQUEST 400 #define HTTP_UNAUTHORIZED 401 #define HTTP_PAYMENT_REQUIRED 402 #define HTTP_FORBIDDEN 403 #define HTTP_NOT_FOUND 404 #define HTTP_METHOD_NOT_ALLOWED 405 #define HTTP_NOT_ACCEPTABLE 406 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407 #define HTTP_REQUEST_TIME_OUT 408 #define HTTP_CONFLICT 409 #define HTTP_GONE 410 #define HTTP_LENGTH_REQUIRED 411 #define HTTP_PRECONDITION_FAILED 412 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413 #define HTTP_REQUEST_URI_TOO_LARGE 414 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415 #define HTTP_INTERNAL_SERVER_ERROR 500 #define HTTP_NOT_IMPLEMENTED 501 #define HTTP_BAD_GATEWAY 502 #define HTTP_SERVICE_UNAVAILABLE 503 #define HTTP_GATEWAY_TIME_OUT 504 #define HTTP_VERSION_NOT_SUPPORTED 505 #define HTTP_VARIANT_ALSO_VARIES 506 #define DOCUMENT_FOLLOWS HTTP_OK #define PARTIAL_CONTENT HTTP_PARTIAL_CONTENT #define MULTIPLE_CHOICES HTTP_MULTIPLE_CHOICES #define MOVED HTTP_MOVED_PERMANENTLY #define REDIRECT HTTP_MOVED_TEMPORARILY #define USE_LOCAL_COPY HTTP_NOT_MODIFIED #define BAD_REQUEST HTTP_BAD_REQUEST #define AUTH_REQUIRED HTTP_UNAUTHORIZED #define FORBIDDEN HTTP_FORBIDDEN #define NOT_FOUND HTTP_NOT_FOUND #define METHOD_NOT_ALLOWED HTTP_METHOD_NOT_ALLOWED #define NOT_ACCEPTABLE HTTP_NOT_ACCEPTABLE #define LENGTH_REQUIRED HTTP_LENGTH_REQUIRED #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED #define SERVER_ERROR HTTP_INTERNAL_SERVER_ERROR #define NOT_IMPLEMENTED HTTP_NOT_IMPLEMENTED #define BAD_GATEWAY HTTP_BAD_GATEWAY #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES #define METHODS 8 #define M_GET 0 #define M_PUT 1 #define M_POST 2 #define M_DELETE 3 #define M_CONNECT 4 #define M_OPTIONS 5 #define M_TRACE 6 #define M_INVALID 7 /* Just in case your linefeed isn't the one the other end is expecting. */ #define LF 0xa #define CR 0xd /* Possible values for request_rec.read_body (set by handling module): * REQUEST_NO_BODY Send 413 error if message has any body * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. * REQUEST_CHUNKED_PASS Pass the chunks to me without removal. */ #define REQUEST_NO_BODY 0 #define REQUEST_CHUNKED_ERROR 1 #define REQUEST_CHUNKED_DECHUNK 2 #define REQUEST_CHUNKED_PASS 3 typedef struct request_rec { char the_request[MAX_STRING_LEN]; /* First line of request, so we can log it */ int assbackwards; /* HTTP/0.9, "simple" request */ int header_only; /* HEAD request, as opposed to GET */ char protocol[LITTLE_STRING_LEN]; /* Protocol, as given to us, or HTTP/0.9 */ int proto_num; /* Number version of protocol; 1.1 = 1001 */ char hostname[LITTLE_STRING_LEN]; /* Host, as set by full URI or Host: */ int hostlen; /* Length of http://host:port in full URI */ char *method; /* GET, HEAD, POST, etc. */ int method_number; /* M_GET, M_POST, etc. */ int allowed; /* Allowed methods - for 405, OPTIONS, etc */ int sent_bodyct; /* byte count in stream is for body */ long bytes_sent; /* body byte count, for easy access */ /* HTTP/1.1 connection-level features */ int chunked; /* sending chunked transfer-coding */ int byterange; /* number of byte ranges */ char *boundary; /* multipart/byteranges boundary */ char *range; /* The Range: header */ long clength; /* The "real" content length */ /* MIME header environments, in and out. Also, an array containing * environment variables to be passed to subprocesses, so people can * write modules to add to that environment. * * The difference between headers_out and err_headers_out is that the * latter are printed even on error, and persist across internal redirects * (so the headers printed for ErrorDocument handlers will have them). * * The 'notes' table is for notes from one module to another, with no * other set purpose in mind... */ hash_table *headers_in; hash_table *headers_out; hash_table *err_headers_out; char *content_type; /* Break these out --- we dispatch on 'em */ char *handler; /* What we *really* dispatch on */ char *content_encoding; char *uri; /* complete URI for a proxy req, or URL path for a non-proxy req */ char *filename; char *path_info; char *query_string ; /* in case of CGI */ char *args; /* QUERY_ARGS, if any */ int client_sock ; }request_rec; int httpReadInputLine(int sock, char *buffer,int buffer_len); #endif