/usr/include/sipxtapi/net/HttpServer.h is in libsipxtapi-dev 3.3.0~test17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | //
// Copyright (C) 2004-2006 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////
#ifndef _HttpServer_h_
#define _HttpServer_h_
// SYSTEM INCLUDES
//#include <...>
// APPLICATION INCLUDES
#include <utl/UtlInt.h>
#include <utl/UtlHashMap.h>
#include <utl/UtlHashBag.h>
#include <os/OsTask.h>
#include <os/OsConfigDb.h>
#include <net/HttpConnection.h>
// DEFINES
#define MAX_PERSISTENT_HTTP_CONNECTIONS 5
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
class HttpMessage;
class HttpBody;
class OsServerSocket;
class OsConnectionSocket;
class HttpRequestContext;
class HttpService;
class HttpConnection;
//:Class short description which may consist of multiple lines (note the ':')
// Class detailed description which may extend to multiple lines
class HttpServer : public OsTask
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
friend class HttpConnection;
/* ============================ CREATORS ================================== */
HttpServer(OsServerSocket *pSocket, OsConfigDb* userPasswordDb,
const char* realm, OsConfigDb* validIpAddressDB = NULL,
bool bPersistentConnection = false);
//:Default constructor
virtual
~HttpServer();
//:Destructor
/* ============================ MANIPULATORS ============================== */
virtual int run(void* runArg);
// Request processors
static void processPostFile(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
static int doPostFile(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response,
UtlString& status);
static void processFileRequest(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
// Error request processors
static void processNotSupportedRequest(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
static void processFileNotFound(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
static void processUserNotAuthorized(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response,
const char* text = 0);
static void createHtmlResponse(int responseCode, const char* responseCodeText,
const char* htmlBodyText, HttpMessage*& response);
static void testCgiRequest(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
static UtlBoolean mapUri(OsConfigDb& configDb, const char* uri, UtlString& mappedUri);
void addUriMap(const char* fromUri, const char* toUri);
typedef void RequestProcessor(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response
);
void addRequestProcessor(const char* fileUrl, RequestProcessor* requestProcessor);
void addHttpService(const char* fileUrl, HttpService* service);
/// set permission for access to mapped file names
void allowFileAccess(bool fileAccess ///< true => allow access, false => disallow access
);
void setPasswordDigest(const char* user, const char* password,
UtlString& userPasswordDigest);
void setPasswordDigest(const char* user, const char* passwordDigest);
//: Sets the password, given an already digested password.
void getDigest(const char* user, const char* password,
UtlString& userPasswordDigest) ;
void setPasswordBasic(const char* user, const char* password);
void removeUser(const char* user, const char* password) ;
static void constructFileList(UtlString & indexText, UtlString uri, UtlString uriFilename) ;
//get current http server status
OsStatus getStatus();
/* ============================ ACCESSORS ================================= */
/* ============================ INQUIRY =================================== */
/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
void processRequest(const HttpMessage& request, ///< request to be dispatched
HttpMessage*& response, ///< build response in this message
const OsConnectionSocket* connection ///< for access to security info
);
UtlBoolean processRequestIpAddr(const UtlString& remoteIp,
const HttpMessage& request,
HttpMessage*& response);
UtlBoolean isRequestAuthorized(const HttpMessage& request,
HttpMessage*& response,
UtlString& userId);
void processPutRequest(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response);
void getFile(const char* fileName, HttpBody*& body);
void putFile(const char* fileName, HttpBody& body);
UtlBoolean findRequestProcessor(const char* fileUri,
RequestProcessor*& requestProcessor
);
UtlBoolean findHttpService(const char* fileUri, HttpService*& service);
void loadValidIpAddrList();
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
HttpServer(const HttpServer& rHttpServer);
//:Copy constructor (disabled)
HttpServer& operator=(const HttpServer& rhs);
//:Assignment operator (disabled)
OsStatus httpStatus;
int mServerPort;
OsServerSocket* mpServerSocket;
OsConfigDb * mpUserPasswordDigestDb;
OsConfigDb * mpUserPasswordBasicDb;
OsConfigDb * mpValidIpAddressDB;
OsConfigDb mUriMaps;
OsConfigDb * mpNonceDb;
UtlString mRealm;
UtlHashMap mRequestProcessorMethods;
UtlHashMap mHttpServices;
bool mAllowMappedFiles;
UtlHashBag mValidIpAddrList;
UtlBoolean mbPersistentConnection;
int mHttpConnections;
UtlSList* mpHttpConnectionList;
};
/* ============================ INLINE METHODS ============================ */
#endif // _HttpServer_h_
|