Click here to Skip to main content
12,350,134 members (24,979 online)
Click here to Skip to main content

Stats

75.3K views
2.2K downloads
47 bookmarked
Posted

STL WebServer

, 8 May 2000
A set of classes written in STL that implement a web server
#if !defined(HttpServer_H)
#define HttpServer_H

#include "HttpRequest.h"
#include "HttpServerInfo.h"
#include "ServerSocketHandler.h"
#include "HttpSocketHandler.h"
#include "TextFile.h"
#include "TimeStamp.h"


#include <vector>
using namespace std;


///////////////////////////////////////////////////////////////////////////////////////
// HttpServer
//
// Purpose:		http server implementation

class HttpServer :
	public HttpServerInfo,
	public CreateSocketHandler
{

	HttpRequestList			_requests;		// list of outstanding requests
	ServerSocket			_serverSocket;
	ServerSocketHandler	*	_handler;

public:

	HttpServer( long noConnections = 10, long port = 80 );
	virtual ~HttpServer();


	// create/release 
	bool	create	( string & server, string & directory );
	void	release	();



	// responsible for create a connection
	SocketHandler * createHandler () 
	{
		// create socket handler attach to server info
		// a ref to http server info is passed in
		return (SocketHandler *) new HttpSocketHandler(*this);
	}


	bool	start			();
	void	stop			();

	void    hit				( HttpRequest & request );
	long    run				();

	bool	urlToPath		( string & strFile );
	bool	pathToUrl		( string & strFile );
	bool	checkDefault	( UINT uList, bool bExecute );
	bool	find			( string & strFile );

	bool	isSvrApp		( void );
	bool	checkExt		( const string& strExt, string& strAvail, DWORD dwType );

	string & getServer ()
	{
		return _strServer;
	}

	bool getListIcon ()
	{
		return _bListIcon;
	}

	bool getAllowListing ()
	{
		return _bAllowListing;
	}

};





#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

David Hubbard
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 9 May 2000
Article Copyright 2000 by David Hubbard
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid