Google
Web alhem.net
Main Page | Alphabetical List | Class List | File List | Class Members | File Members

RedirWwwSocket Class Reference

#include <RedirWwwSocket.h>

List of all members.

Public Member Functions

 RedirWwwSocket (ISocketHandler &)
 ~RedirWwwSocket ()
void OnLine (const std::string &)

Private Attributes

std::string m_method
std::string m_url


Detailed Description

File ......... RedirWwwSocket.h Published .... 2004-04-18 Author ....... grymse@alhem.net

Definition at line 32 of file RedirWwwSocket.h.


Constructor & Destructor Documentation

RedirWwwSocket::RedirWwwSocket ISocketHandler &   ) 
 

Definition at line 38 of file RedirWwwSocket.cpp.

00039 :TcpSocket(h)
00040 {
00041         SetLineProtocol();
00042 }

RedirWwwSocket::~RedirWwwSocket  ) 
 

Definition at line 45 of file RedirWwwSocket.cpp.

00046 {
00047 }


Member Function Documentation

void RedirWwwSocket::OnLine const std::string &   ) 
 

Definition at line 50 of file RedirWwwSocket.cpp.

References DEB, m_method, and m_url.

00051 {
00052         Parse pa(line,":");
00053         std::string key = pa.getword();
00054 
00055 DEB(    printf("%s\n",line.c_str());)
00056 
00057         if (key == "GET")
00058         {
00059                 m_method = key;
00060                 m_url = pa.getword();
00061         }
00062         else
00063         if (key == "")
00064         {
00065                 std::string response;
00066                 if (m_method == "GET")
00067                 {
00068                         HOST *p = static_cast<MyHandler&>(Handler()).GetRandomHOST( "viawww", true );
00069                         if (p)
00070                         {
00071                                 std::string ip;
00072                                 Utility::l2ip(p -> ip, ip);
00073                                 response = "HTTP/1.0 302 Moved\n"
00074                                         "Location: http://" + ip + ":8080" + m_url + "\n"
00075                                         "\n";
00076                                 Send(response);
00077 DEB(                            printf("Response:\n%s\n",response.c_str());)
00078                                 SetCloseAndDelete();
00079                         }
00080                         else
00081                         {
00082 DEB(                            printf("no random host found\n");)
00083                                 response = "HTTP/1.0 404 Not Found\n"
00084                                         "Content-Type: text/html\n"
00085                                         "\n"
00086                                         "<html><body><h1>Document not found</ht></body></html>";
00087                                 Send(response);
00088                                 SetCloseAndDelete();
00089                         }
00090                 }
00091                 else
00092                 {
00093 DEB(                    printf("m_method != GET ('%s')\n",m_method.c_str());)
00094                         SetCloseAndDelete();
00095                 }
00096         }
00097 }


Member Data Documentation

std::string RedirWwwSocket::m_method [private]
 

Definition at line 41 of file RedirWwwSocket.h.

Referenced by OnLine().

std::string RedirWwwSocket::m_url [private]
 

Definition at line 42 of file RedirWwwSocket.h.

Referenced by OnLine().


The documentation for this class was generated from the following files:
Generated on Tue Oct 3 23:47:05 2006 for The Minder by doxygen 1.3.6