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

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

Increased the maximum URL length for the local library to 8kB and fixed
a nasty little array indexing bug.

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