[2286] | 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 |
|
---|
[611] | 28 | #ifndef HTTPREQ_H
|
---|
| 29 | #define HTTPREQ_H
|
---|
| 30 |
|
---|
[3810] | 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>
|
---|
| 35 | using namespace std;
|
---|
| 36 | #endif
|
---|
| 37 |
|
---|
[2038] | 38 | #include "locate.h"
|
---|
[2280] | 39 | #include "text_t.h"
|
---|
[2038] | 40 |
|
---|
[611] | 41 | /*
|
---|
[2286] | 42 | Module Name: HTTP Request
|
---|
[611] | 43 | Purpose: Parses HTTP requests and then calls the appropriate function
|
---|
| 44 | to respond to the request
|
---|
| 45 | Public Functions:
|
---|
| 46 | Request Thread
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 | // Public Data Structures
|
---|
| 50 |
|
---|
| 51 | //Used for sending information to the request thread
|
---|
| 52 | struct RequestThreadMessageT {
|
---|
[2286] | 53 | SOCKADDR_IN ClientSockAddr;
|
---|
| 54 | SOCKET ClientSocket;
|
---|
| 55 | int AddrLen;
|
---|
| 56 | };
|
---|
[611] | 57 |
|
---|
| 58 | #define MAX_OTHER_HEADERS 100
|
---|
| 59 |
|
---|
| 60 | struct RequestHeaderT {
|
---|
[3810] | 61 | text_t Var;
|
---|
| 62 | text_t Val;
|
---|
[2280] | 63 | };
|
---|
[611] | 64 |
|
---|
| 65 | struct RequestFieldsT {
|
---|
[2280] | 66 | //Simple request line info v0.9
|
---|
[3810] | 67 | text_t MethodStr;
|
---|
[2280] | 68 | text_t URIStr;
|
---|
| 69 | //added v1.0
|
---|
[3810] | 70 | text_t VersionStr;
|
---|
[2280] | 71 | //General Header
|
---|
[3810] | 72 | text_t DateStr;
|
---|
| 73 | text_t MIMEVerStr;
|
---|
| 74 | text_t PragmaStr;
|
---|
[2280] | 75 | //Request Header
|
---|
[3810] | 76 | text_t AuthorizationStr;
|
---|
| 77 | text_t FromStr;
|
---|
| 78 | text_t IfModSinceStr;
|
---|
| 79 | text_t RefererStr;
|
---|
| 80 | text_t UserAgentStr;
|
---|
[2280] | 81 | //Entity Header (Only CGI stuff)
|
---|
[3810] | 82 | text_t ContentEncodingStr;
|
---|
| 83 | text_t ContentTypeStr;
|
---|
| 84 | text_t ContentLengthStr;
|
---|
[2280] | 85 | //v1.0 Optional (the more common ones)
|
---|
[3810] | 86 | text_t AcceptStr;
|
---|
| 87 | text_t AcceptLangStr;
|
---|
[2280] | 88 | //v1.1 Exentions
|
---|
[3810] | 89 | text_t ConnectionStr;
|
---|
[2280] | 90 | //Pointer to buffer containing the content
|
---|
| 91 | DWORD ContentLength;
|
---|
| 92 | BYTE *Content;
|
---|
| 93 |
|
---|
| 94 | //Other Headers
|
---|
| 95 | int NumOtherHeaders;
|
---|
| 96 | RequestHeaderT OtherHeaders[MAX_OTHER_HEADERS];
|
---|
| 97 | };
|
---|
[611] | 98 |
|
---|
| 99 | struct RequestInfoT {
|
---|
[2280] | 100 | int ThreadNum;
|
---|
| 101 |
|
---|
| 102 | //Buffer for IO operations (so we're not constantly reallocating buffers)
|
---|
| 103 | BYTE *IOBuffer;
|
---|
| 104 | int IOBufferSize;
|
---|
| 105 |
|
---|
| 106 | //Socket the request is on and its address
|
---|
| 107 | SOCKET ClientSocket;
|
---|
| 108 | SOCKADDR_IN ClientSockAddr;
|
---|
| 109 | int AddrLen;
|
---|
| 110 |
|
---|
| 111 | //Should we keep the connection alive?
|
---|
| 112 | BOOL KeepAlive;
|
---|
| 113 | };
|
---|
[611] | 114 |
|
---|
| 115 |
|
---|
| 116 | // Public Functions
|
---|
| 117 |
|
---|
| 118 | /*
|
---|
| 119 | Function Name: RequestThread
|
---|
| 120 | Purpose: Was the HTTP request processing thread
|
---|
| 121 | Now just a standard procedure called to process a request
|
---|
| 122 | Parameters:
|
---|
| 123 | Pointer to packed parameter structure
|
---|
| 124 | */
|
---|
| 125 | void RequestThread(RequestThreadMessageT *Parameters);
|
---|
| 126 |
|
---|
| 127 | /*
|
---|
| 128 | Function Name: Process 1.0 Request
|
---|
| 129 | Purpose: Sends a HTTP 1.0 (plus some) reply to a HTTP 1.x request
|
---|
| 130 | Parameters:
|
---|
| 131 | ClientSocket - Socket the client is on
|
---|
| 132 | ClientSockAddr - Address of client
|
---|
| 133 | AddrLen - Length of client address
|
---|
| 134 | RequestInfo - Structure storing the parsed headers
|
---|
| 135 | KeepAlive - To be set to true if we are maintainig the connection
|
---|
| 136 | IOBuffer - Pointer to buffer allocated for IO operations
|
---|
| 137 | TheadNum - Number of calling thread for debugging
|
---|
| 138 | Notes: The function uses "Connection: Keep-Alive" as written in the HTTP/1.1
|
---|
| 139 | draft and implemented by Netscape and MSIE
|
---|
| 140 | */
|
---|
| 141 | void Process10Request(RequestInfoT &RequestInfo, RequestFieldsT &RequestFields);
|
---|
| 142 |
|
---|
| 143 | #endif
|
---|