source: main/trunk/greenstone2/runtime-src/src/w32server/httpreq.h@ 22452

Last change on this file since 22452 was 18313, checked in by davidb, 15 years ago

Fixed bug to do with initialization of RequestFields variable. Had been using a memset to make it all zero, but this is not a safe thing to do when there are text_t fields in the class. Code upgraded to use a constructor and 'reset' function that explicitly initializes and clears the text_t fields

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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#define MAX_OTHER_HEADERS 100
59
60struct RequestHeaderT {
61 text_t Var;
62 text_t Val;
63
64 RequestHeaderT()
65 : Var(), Val()
66 {}
67};
68
69struct RequestFieldsT {
70 //Simple request line info v0.9
71 text_t MethodStr;
72 text_t URIStr;
73 //added v1.0
74 text_t VersionStr;
75 //General Header
76 text_t DateStr;
77 text_t MIMEVerStr;
78 text_t PragmaStr;
79 //Request Header
80 text_t AuthorizationStr;
81 text_t FromStr;
82 text_t IfModSinceStr;
83 text_t RefererStr;
84 text_t UserAgentStr;
85 //Entity Header (Only CGI stuff)
86 text_t ContentEncodingStr;
87 text_t ContentTypeStr;
88 text_t ContentLengthStr;
89 //v1.0 Optional (the more common ones)
90 text_t AcceptStr;
91 text_t AcceptLangStr;
92 //v1.1 Exentions
93 text_t ConnectionStr;
94 //Pointer to buffer containing the content
95 DWORD ContentLength;
96 BYTE *Content;
97
98 //Other Headers
99 int NumOtherHeaders;
100 RequestHeaderT OtherHeaders[MAX_OTHER_HEADERS];
101
102 RequestFieldsT()
103 : MethodStr(), URIStr(), VersionStr(), DateStr(), MIMEVerStr(),
104 PragmaStr(), AuthorizationStr(), FromStr(), IfModSinceStr(),
105 RefererStr(), UserAgentStr(), ContentEncodingStr(),
106 ContentTypeStr(), ContentLengthStr(), AcceptStr(),
107 AcceptLangStr(), ConnectionStr(),
108 OtherHeaders()
109 {
110 ContentLength = 0;
111 Content = NULL;
112 NumOtherHeaders = 0;
113 }
114
115};
116
117struct RequestInfoT {
118 int ThreadNum;
119
120 //Buffer for IO operations (so we're not constantly reallocating buffers)
121 BYTE *IOBuffer;
122 int IOBufferSize;
123
124 //Socket the request is on and its address
125 SOCKET ClientSocket;
126 SOCKADDR_IN ClientSockAddr;
127 int AddrLen;
128
129 //Should we keep the connection alive?
130 BOOL KeepAlive;
131};
132
133
134// Public Functions
135
136/*
137Function Name: RequestThread
138Purpose: Was the HTTP request processing thread
139 Now just a standard procedure called to process a request
140Parameters:
141 Pointer to packed parameter structure
142*/
143void RequestThread(RequestThreadMessageT *Parameters);
144
145/*
146Function Name: Process 1.0 Request
147Purpose: Sends a HTTP 1.0 (plus some) reply to a HTTP 1.x request
148Parameters:
149 ClientSocket - Socket the client is on
150 ClientSockAddr - Address of client
151 AddrLen - Length of client address
152 RequestInfo - Structure storing the parsed headers
153 KeepAlive - To be set to true if we are maintainig the connection
154 IOBuffer - Pointer to buffer allocated for IO operations
155 TheadNum - Number of calling thread for debugging
156Notes: The function uses "Connection: Keep-Alive" as written in the HTTP/1.1
157 draft and implemented by Netscape and MSIE
158*/
159void Process10Request(RequestInfoT &RequestInfo, RequestFieldsT &RequestFields);
160
161#endif
Note: See TracBrowser for help on using the repository browser.