private void WritePacket(NameValueCollection httpHeaders, String pathInfo, int sourcePort=0, String vDirs="")
{
//set defaults first
bool is_ssl = (GetKeyValue(httpHeaders, "HTTPS") == "on"); //is HTTPS == "on"
//set values from header information
string protocol = GetKeyValue(httpHeaders, "SERVER_PROTOCOL"); // "HTTP/1.1"
int num_headers = 0; //httpHeaders.AllKeys.Length; // -lstSystemBlacklist.Length;
byte method = BonCodeAJP13PacketHeaders.GetMethodByte(GetKeyValue(httpHeaders, "REQUEST_METHOD"));
string req_uri = GetKeyValue(httpHeaders, "SCRIPT_NAME");
string remote_addr = GetRemoteAddr(httpHeaders); // GetKeyValue(httpHeaders, "REMOTE_ADDR"); GetRemoteAddr(httpHeaders);
string remote_host = GetKeyValue(httpHeaders, "REMOTE_HOST");
string server_name = GetKeyValue(httpHeaders, "HTTP_HOST"); //BonCodeAJP13Settings.BONCODEAJP13_SERVER;
ushort server_port = System.Convert.ToUInt16(GetKeyValue(httpHeaders, "SERVER_PORT")); // System.Convert.ToUInt16(BonCodeAJP13Settings.BONCODEAJP13_PORT);
//BonCodeAJP13Logger.LogDebug(String.Format("{0} {1} {2} {3} {4} {5} [{6}]", this.ConnectionId, remote_addr, GetKeyValue(httpHeaders, "REQUEST_METHOD"), server_name, req_uri, GetKeyValue(httpHeaders, "QUERY_STRING"), GetKeyValue(httpHeaders, "HTTP_USER_AGENT")));
//call alternate method to complete writing of forward request packet. Final data will be stored in in p_ByteStore instance var
try
{
WritePacket(method, protocol, req_uri, remote_addr, remote_host, server_name, server_port, is_ssl, num_headers, httpHeaders, pathInfo, sourcePort,vDirs);
}
catch (Exception exp)
{
//error write details to special log file
if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL >= BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS)
{
/* DEBUG SPECIAL CODE START
string fileName = BonCodeAJP13Logger.GetLogDir() + "\\BonCodeAJP13LastAJPException.log";
string fo = "M:" + method.ToString() + "\r\n";
fo = fo + "P:" + protocol.ToString() + "\r\n";
fo = fo + "URI:" + req_uri.ToString() + "\r\n";
fo = fo + "ADDR:" + remote_addr.ToString() + "\r\n";
fo = fo + "HOST:" + remote_host.ToString() + "\r\n";
fo = fo + "SERVER:" + server_name.ToString() + "\r\n";
fo = fo + "PORT:" + server_port.ToString() + "\r\n";
fo = fo + "SSL:" + is_ssl.ToString() + "\r\n";
fo = fo + "PI:" + pathInfo.ToString() + "\r\n";
fo = fo + "SP:" + sourcePort.ToString() + "\r\n";
if (httpHeaders != null)
{
fo = fo + GetHeaders(httpHeaders);
}
else
{
fo = fo + "NO HEADERS \r\n";
}
//stack trace
fo = fo + "STACK \r\n";
fo = fo + exp.StackTrace;
//write file (this is not
TextWriter tw = new StreamWriter(fileName);
// write text to file
tw.WriteLine(fo);
// close the stream
tw.Close();
DEBUG SPECIAL CODE END */
//rethrow
throw;
}
}
}