Index: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp	(revision 44)
+++ trunk/src/main.cpp	(revision 45)
@@ -68,76 +68,4 @@
 }
 
-THREAD_FUNCTION_RETURN
-THREAD_FUNCTION_CALLING_CONVENTION
-CRXProxyMTWrapper (void * aThreadArg)
-{
-	int			aResult = 0;
-
-	CRXSocket	* aProxySocket = (CRXSocket *)aThreadArg;
-	CRXProxy	* aProxy = NULL;
-
-	char		aFilterFileExtension[] = "exe|gif|jpg|png|css|js|ico|swf|";
-	char		* aHttpMessage = NULL;
-	int			aHttpMessageLength = 0;
-
-	/*----------------------------------------------------------------*/
-	for (;;)
-	{
-		aResult = aProxySocket->Accept ();
-		if (aResult < 0)
-		{
-			cerr << "Failed to accept." << endl;
-			break;
-		}
-
-		if ((aProxy = new(std::nothrow) CRXProxy ()) == NULL)
-		{
-			cerr << "Failed to get proxy." << endl;
-			aResult = -1;
-			break;
-		}
-
-		aProxy->SetClientSocket (aResult);
-		aProxy->SetServerTimeout (2);
-		aProxy->SetRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION,
-								  CRX_FILTER_MATCHED,
-								  aFilterFileExtension);
-
-		aResult = aProxy->Forward ();
-		if (aResult < 0)
-		{
-			cout << aProxy->GetErrorMessage () << endl;
-		}
-
-		if (!aProxy->CheckRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION))
-		{
-			aHttpMessageLength = aProxy->GetHttpRequestLength ();
-			aHttpMessage = (char *) calloc (aHttpMessageLength + 1, 1);
-			aProxy->GetHttpRequest (aHttpMessage, aHttpMessageLength);
-			CRX_DEBUG_TRACE ("== Request: \n%s\n", aHttpMessage);
-			free (aHttpMessage);
-
-			aHttpMessageLength = aProxy->GetHttpResponseHeaderLength ();
-			aHttpMessage = (char *) calloc (aHttpMessageLength + 1, 1);
-			aProxy->GetHttpResponseHeader (aHttpMessage, aHttpMessageLength);
-			CRX_DEBUG_TRACE ("== Response: \n%s\n", aHttpMessage);
-			free (aHttpMessage);
-
-			aHttpMessageLength = aProxy->GetHttpResponseBodyLength ();
-			aHttpMessage = (char *) calloc (aHttpMessageLength + 1, 1);
-			aProxy->GetHttpResponseBody (aHttpMessage, aHttpMessageLength);
-			CRX_DEBUG_TRACE_BIN (aHttpMessage, aHttpMessageLength, "== Content-Body: \n");
-			free (aHttpMessage);
-		}
-
-		delete aProxy;
-	}
-
-	cout << " thread exit." << endl;
-	/*----------------------------------------------------------------*/
-
-	return (THREAD_FUNCTION_RETURN)0;
-}
-
 int ThreadPool (CRXSocket	* aProxySocket,
 				const int	aThreadPoolCount)
@@ -171,2 +99,65 @@
 	return aResult;
 }
+
+THREAD_FUNCTION_RETURN
+THREAD_FUNCTION_CALLING_CONVENTION
+CRXProxyMTWrapper (void * aThreadArg)
+{
+	int			aResult = 0;
+
+	CRXSocket	& aProxySocket = *((CRXSocket *)aThreadArg);
+	CRXProxy	* aProxy = NULL;
+
+	char		aFilterFileExtension[] = "exe|gif|jpg|png|css|js|ico|swf|";
+
+	/*----------------------------------------------------------------*/
+	for (;;)
+	{
+		aResult = aProxySocket.Accept ();
+		if (aResult < 0)
+		{
+			cerr << aProxySocket.GetErrorMessage () << endl;
+			aResult = -1;
+			break;
+		}
+
+		aProxy = new(std::nothrow) CRXProxy (aResult);
+		if (aProxy == NULL)
+		{
+			cerr << "Failed to get proxy." << endl;
+			aResult = -1;
+			break;
+		}
+		aProxy->SetServerTimeout (2);
+
+		CRXFilter		& aFilter	= aProxy->GetFilter ();
+		CRXHttpRequest	& aRequest	= aProxy->GetHttpRequest ();
+		CRXHttpResponse	& aResponse	= aProxy->GetHttpResponse ();
+
+		aFilter.SetRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION,
+								  CRX_FILTER_MATCHED,
+								  aFilterFileExtension);
+
+		aResult = aProxy->Forward ();
+		if (aResult < 0)
+		{
+			cerr << aProxy->GetErrorMessage () << endl;
+		}
+
+		if (!aFilter.CheckRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION, aRequest))
+		{
+			CRX_DEBUG_TRACE ("== Request:  \n%s\n", aRequest.GetHeader ().c_str ());
+			CRX_DEBUG_TRACE ("== Response: \n%s\n", aResponse.GetHeader ().c_str ());
+			CRX_DEBUG_TRACE_BIN (aResponse.GetContentBody (),
+								 aResponse.GetContentLength (),
+								 "== Content-Body: \n");
+		}
+
+		delete aProxy;
+	}
+
+	cout << " thread exit." << endl;
+	/*----------------------------------------------------------------*/
+
+	return (THREAD_FUNCTION_RETURN)0;
+}
