zip attachment can be found at http://www.cornerstone.co.nz/temp/aspnetbug.zip

Note in hindsight printvars.c is not actually required now I found that GetServerVariables is working correctly.

Or alternatively:

=== aspnetbug.conf
usual mod_aspdotnet stuff plus

AspNetMount /aspnetbug "C:/temp/aspnetbug"
Alias /aspnetbug "C:/temp/aspnetbug"

# Enable scripts to be executed in this directory
<Directory "C:/temp/aspnetbug">
   Options FollowSymlinks ExecCGI
   Order allow,deny
   Allow from all

   # enable printvars.exe to run
   AddHandler cgi-script .exe

# Require authentication
AuthType basic
AuthName "Test mod_aspdotnet bug"
AuthUserFile "conf/bugusers"
Require user test
</Directory>


=== bugusers
test:$apr1$JW4.....$bb.7.q9roAcdOmDgh2OyK.

=== printvars.aspx
<%@ Page Language="C#" %>
<html>
<body>

<h2>Results of reading (IIS/Apache) Server Variables</h2>
<p>Left column is in the ASP.NET Request.ServerVariables[] collection</p>
<p>Right column is what the WorkerRequest.GetServerVariable() method returns</p>
<p>Spot the difference!</p>


<%
// Get direct access to the server variables via the Workerrequest object.
IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpRequest util = (HttpRequest) provider.GetService(typeof(HttpRequest));
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));


// And print the variables from the two sources

Response.Write( "<table cellpadding=\"2px\">\n" );
Response.Write( "<tr><td>Variable</td><td>ServerVariables[x]<br />collection</td><td>GetServerVariables(x)<br />method</td></tr>" );
Response.Write( String.Format(
"<tr><td>AUTH_TYPE</td><td>{0}</td><td>{1}</td></tr>\n",
Request.ServerVariables["AUTH_TYPE"], wr.GetServerVariable("AUTH_TYPE") ) );
Response.Write( String.Format(
"<tr><td>AUTH_USER</td><td>{0}</td><td>{1}</td></tr>\n",
Request.ServerVariables["AUTH_USER"], wr.GetServerVariable("AUTH_USER") ) );
Response.Write( String.Format(
"<tr><td>REMOTE_USER</td><td>{0}</td><td>{1}</td></tr>\n",
Request.ServerVariables["REMOTE_USER"], wr.GetServerVariable("REMOTE_USER") ) );
Response.Write( String.Format(
"<tr><td>SERVER_SOFTWARE</td><td>{0}</td><td>{1}</td></tr>\n",
Request.ServerVariables["SERVER_SOFTWARE"], wr.GetServerVariable("SERVER_SOFTWARE") ) );
Response.Write( "</table>\n" );
%>


</body>
</html>

=== printvars.c

#include <ctype.h>
#include <stdio.h>
#include <string.h>

char * interesting_vars[] =
{
"AUTH_TYPE", "AUTH_USER", "REMOTE_USER", "SERVER_SOFTWARE", NULL
};


int main(int argc, char **argv, char **arge )
{
char **pEnv, **pTest, *p; size_t len;
printf( "Status: 200 OK\n" );
printf( "Content-type: text/plain\n" );
printf( "\n");
for( pEnv = arge; NULL != *pEnv; ++pEnv )
{
// does it match one of the interesting ones?
for( p= *pEnv; *p!='\0'&&*p!='='; ++p ) { } // find = or null
while( p>*pEnv && isspace(*(p-1)) ) { --p; } // skip whitespace
for( pTest = interesting_vars; NULL!=*pTest; ++pTest )
{
len = (size_t)(p-*pEnv);
if( strlen(*pTest)==len && 0==strnicmp(*pEnv,*pTest,len) )
{
printf( "%s\n", *pEnv );
break;//for
}
}
}


   return 0;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to