Ok, heres a quick overview:
CONNECTION.HPP
Code:
#include....
class CONNECTION
{
public:
CONNECTION(int SFD_SET, struct sockaddr_in);// Constructor
CONNECTION();
bool LogConnection(); // Logs connection to the appropriate log
bool ReadRequest(); // Reads the request and sets values
bool HandleRequest(); // Handles the request
private:
// Methods
bool SetFileType(); // Sets if the file is a script or binary
bool IndexFolder(); // Indexes the folder by listing all the files
bool SendText(); // Sends the requested file if it is text
bool SendCGI(); // Sends the requested file if it is a script
bool SendBinary(); // Sends the requested file if it is binary
bool SendError(); // Outputs the appropriate error code
bool LogText(string); // Logs some text. Used only for testing
string CalculateSize(); // Outputs the file size
bool ModifiedSince(string Date); // Was the file modifed since...
bool UnModifiedSince(string Date); // Is the file Unmodified since...
// Properties
int SFD; // Socket descriptor of connection
struct sockaddr_in ClientAddress; // Client address structure
VIRTUALHOST *ThisHost; // This virtual host host
string FullRequest; // The entire input from the client
string RequestType; // Type of request (POST, GET etc)
string FileRequested; // String folling GET
string QueryString; // Anything after the '?' in the file
string Extension; // Extension of file requested
string RealFile; // Real path to file
etc etc....
};
Connection.Cpp
Code:
CONNECTION::CONNECTION(int SFD_SET, struct sockaddr_in CA)
{
SFD = SFD_SET; // Set the socket descriptor
ClientAddress = CA; // Assign the client address
UseVH = false; // Dont use a Virtual host by default
IsFolder = false; // By default its not a folder
IsBinary = false; // Nor is it binary
IsScript = false; // Or a CGI script
IsAbsolute = false; // And the URL is not an absolute URL
Status = 200; // But the file is always served fine
}
etc etc... with all the members (yes all).
Both files have the usual #ifdef SOMETHING #define SOMETHING etc, so that shouldn't be a problem.
Maybe its because I gave them .hpp extensions rather than .h? Could that be the solution?