I have a small java program (excerpted below) which sends a couple of headers along with an HTTP GET request.
- Code: Select all
import java.net.*;
import java.io.*;
public class HTTPGetTest
{
public static void main(String args[]) throws Exception
{
int i = -1;
URL url = new URL("http://myserver.mydomain.com/cgi-bin/printenv");
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
urlConn.setRequestMethod("GET");
urlConn.setRequestProperty("userid", "myuser");
urlConn.setRequestProperty("password", "mypassword");
urlConn.connect();
if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
while ((i = in.read()) != -1)
System.out.print((char) i);
}
}
}
However, the constraint I have is that the actual java program will not have the two lines to set the headers. Can I achieve the exact same effect of these lines using mod_rewrite? I have so far tried -
- Code: Select all
RewriteRule /cgi-bin/printenv - [env=userid:myuser,env=password:mypassword,L]
and
- Code: Select all
RewriteRule /cgi-bin/printenv - [env=HTTP_userid:myuser,env=HTTP_password:mypassword,L]
But there seems to be a nuance I'm missing - both of these do not seem to set the header the way the the java code does.
I would greatly appreciate any pointers you could give me.
Thanks,
Vinod