I've an annoying ASP.NET problem:
I have a Perl script (see below), which gets the form_info variable. Now unfortunately, it's http POST, and not http GET, so Request.Querystring doesn't work...
Now I have to replace the Perl Script with an asp.net page/app, but my problem is that I cannot process the string form_info when I don't have the string... and I cannot change the http POST to a HTTP get, since it's generated by a 3rd party java applet.
# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";
#
#test whether it's via a firewall (i.e. GET multiple times)
# or direct, i.e. POST
$method = $ENV{'REQUEST_METHOD'};
if ($method eq "GET") {
$form_info = $ENV{'QUERY_STRING'};
print LOGFILE "Method found was: REQUEST_METHOD\n";
}
elsif ($method eq "POST"){
# Get the input
$data_size = $ENV{'CONTENT_LENGTH'};
read(STDIN,$form_info,$data_size);
print LOGFILE "\nMethod found was: POST\n";
}
else {
print "Client used unsupported method";
print LOGFILE "\nMethod found was: Client used unsupported method\n";
}
my assumption is, some code like this is used in the applet:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class PostMethodExample {
public static void main(String args[]) {
HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", "Test Client");
BufferedReader br = null;
PostMethod method = new PostMethod("http://search.yahoo.com/search");
method.addParameter("p", "\"java2s\"");
try{
int returnCode = client.executeMethod(method);
if(returnCode == HttpStatus.SC_NOT_IMPLEMENTED) {
System.err.println("The Post method is not implemented by this URI");
// still consume the response body
method.getResponseBodyAsString();
} else {
br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
String readLine;
while(((readLine = br.readLine()) != null)) {
System.err.println(readLine);
}
}
} catch (Exception e) {
System.err.println(e);
} finally {
method.releaseConnection();
if(br != null) try { br.close(); } catch (Exception fe) {}
}
}
}