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

Last change on this file since 3810 was 3810, checked in by sjboddie, 21 years ago

Removed some hard string length limits in local library server code

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