I have been writing an HTTP server in C#, and I've gotten to the point where I want to implement PHP. However, I cannot seem to find a way to pass POST variables to the PHP-CGI executable. I know that I am supposed to use environment variables to communicate with the executable, and most importantly the QUERY_STRING variable. This one just seems to pass GET variables to PHP, not POST. I've also tried writing to the input stream of the executable, but it just ignores that completely. What am I missing?
A:
You need to write to the input stream of the executable. Did you make sure to set the CONTENT_LENGTH environment variable?
Byron Whitlock
2009-10-06 21:38:51
Well, I only recently found out that I should use environment variables with the executable, so I haven't really added any of them yet. Will PHP wait for me to write to the input stream if I specify the CONTENT_LENGTH?
Bevin
2009-10-06 21:41:38
It shouldn't close the connection until content-length is received, or it timesout.
Byron Whitlock
2009-10-06 21:44:10
I've tried adding the environment variable to the Process object, but it is still not working. When I looked at the keys in the dictionary of variables, they were all small letters. Are the variables case-sensitive?
Bevin
2009-10-07 12:36:12
Perhaps I need to specify REQUEST_METHOD as well.
Bevin
2009-10-07 12:37:55
Now it works! I needed to specify CONTENT_LENGTH and SCRIPT_FILENAME for it to work.
Bevin
2009-10-07 15:42:39