source: trunk/gsdl/src/w32server/httpreq.h@ 2280

Last change on this file since 2280 was 2280, checked in by sjboddie, 23 years ago

In the process of making some changes to the old fnord webserver code.
Note that this version is BROKEN, I just committed it so I could continue
the work I've been doing on my home PC at work.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1#ifndef HTTPREQ_H
2#define HTTPREQ_H
3
4#include "locate.h"
5#include "text_t.h"
6
7/*
8Copyright (C) 1996
9
10This program is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 2 of the License, or
13(at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24The author can be contacted via Email at [email protected]
25*/
26
27/*
28Module Name: HTTP Reqeust
29Purpose: Parses HTTP requests and then calls the appropriate function
30 to respond to the request
31Public Functions:
32 Request Thread
33*/
34
35// Public Data Structures
36
37//Used for sending information to the request thread
38struct RequestThreadMessageT {
39 SOCKADDR_IN ClientSockAddr;
40 SOCKET ClientSocket;
41 int AddrLen;
42 };
43
44//Length constants for RequestFieldsT
45#define ReqMethodStrLen 24
46//#define ReqURIStrLen 255
47#define ReqVersionStrLen 24
48#define ReqDateStrLen 48
49#define ReqMIMEVerStrLen 24
50#define ReqPragmaStrLen 128
51#define ReqAuthorizationStrLen 512
52#define ReqFromStrLen 128
53#define ReqIfModSinceStrLen 48
54#define ReqRefererStrLen 512
55#define ReqUserAgentStrLen 256
56#define ReqContentEncodingStrLen 128
57#define ReqContentTypeStrLen 128
58#define ReqContentLengthStrLen 48
59#define ReqAcceptStrLen 256
60#define ReqAcceptLangStrLen 48
61#define ReqConnectionStrLen 24
62#define ReqAuthorizedUserStrLen 48
63#define ReqPathInfoStrLen 512
64#define ReqPathTranslatedStrLen 512
65#define ReqScriptNameStrLen 512
66// ---
67// 4436
68
69#define MAX_OTHER_HEADERS 100
70
71struct RequestHeaderT {
72 char *Var;
73 char *Val;
74};
75
76struct RequestFieldsT {
77 //Simple request line info v0.9
78 char MethodStr[ReqMethodStrLen];
79 // char URIStr[ReqURIStrLen];
80 text_t URIStr;
81 //added v1.0
82 char VersionStr[ReqVersionStrLen];
83 //General Header
84 char DateStr[ReqDateStrLen];
85 char MIMEVerStr[ReqMIMEVerStrLen];
86 char PragmaStr[ReqPragmaStrLen];
87 //Request Header
88 char AuthorizationStr[ReqAuthorizationStrLen];
89 char FromStr[ReqFromStrLen];
90 char IfModSinceStr[ReqIfModSinceStrLen];
91 char RefererStr[ReqRefererStrLen];
92 char UserAgentStr[ReqUserAgentStrLen];
93 //Entity Header (Only CGI stuff)
94 char ContentEncodingStr[ReqContentEncodingStrLen];
95 char ContentTypeStr[ReqContentTypeStrLen];
96 char ContentLengthStr[ReqContentLengthStrLen];
97 //v1.0 Optional (the more common ones)
98 char AcceptStr[ReqAcceptStrLen];
99 char AcceptLangStr[ReqAcceptLangStrLen];
100 //v1.1 Exentions
101 char ConnectionStr[ReqConnectionStrLen];
102 //Pointer to buffer containing the content
103 DWORD ContentLength;
104 BYTE *Content;
105
106 //Authorized user, filled in if a user is authorized from Auth..Str above
107 char AuthorizedUserStr[ReqAuthorizedUserStrLen];
108
109 //CGI style fields
110 char PathInfoStr[ReqPathInfoStrLen];
111 char PathTranslatedStr[ReqPathTranslatedStrLen];
112 char ScriptNameStr[ReqScriptNameStrLen];
113
114 //Other Headers
115 int NumOtherHeaders;
116 RequestHeaderT OtherHeaders[MAX_OTHER_HEADERS];
117};
118
119struct RequestInfoT {
120 int ThreadNum;
121
122 //Buffer for IO operations (so we're not constantly reallocating buffers)
123 BYTE *IOBuffer;
124 int IOBufferSize;
125
126 //Socket the request is on and its address
127 SOCKET ClientSocket;
128 SOCKADDR_IN ClientSockAddr;
129 int AddrLen;
130
131 //Should we keep the connection alive?
132 BOOL KeepAlive;
133};
134
135
136// Public Functions
137
138/*
139Function Name: RequestThread
140Purpose: Was the HTTP request processing thread
141 Now just a standard procedure called to process a request
142Parameters:
143 Pointer to packed parameter structure
144*/
145void RequestThread(RequestThreadMessageT *Parameters);
146
147/*
148Function Name: Process 1.0 Request
149Purpose: Sends a HTTP 1.0 (plus some) reply to a HTTP 1.x request
150Parameters:
151 ClientSocket - Socket the client is on
152 ClientSockAddr - Address of client
153 AddrLen - Length of client address
154 RequestInfo - Structure storing the parsed headers
155 KeepAlive - To be set to true if we are maintainig the connection
156 IOBuffer - Pointer to buffer allocated for IO operations
157 TheadNum - Number of calling thread for debugging
158Notes: The function uses "Connection: Keep-Alive" as written in the HTTP/1.1
159 draft and implemented by Netscape and MSIE
160*/
161void Process10Request(RequestInfoT &RequestInfo, RequestFieldsT &RequestFields);
162
163#endif
Note: See TracBrowser for help on using the repository browser.