Re: [PHP] POST without Content-Type?
After struggling with this for a bit, I determined that the problem was not in fact with PHP but with Apache. I wound up writing a mod_perl Apache module which took an incoming request to a particular location and parsed out the stream to find the POST content, and inserted it into the HTTP header. That allowed PHP to get access to it... Hope this helps someone down the line. Chris. On Sat, 25 Aug 2001, Rasmus Lerdorf wrote: > Well, first of all, you are using an ancient version of PHP. That message > was changed from a fatal error to a warning over a year ago. > > And if you really want to have PHP accept non-typed POST data, it's an > obvious one-line change in main/SAPI.c > > -Rasmus > > On Sat, 25 Aug 2001, Chris Maresca wrote: > > > > > All, > > > > I've been coding a PHP page that listens for a connection from an embedded > > device (a piece of hardware) that sends a POST query to Apache (and to my > > PHP pages...). > > > > I've having a problem that I can't seem to solve. The embedded > > application does not set a Content-Type header on the POST, so PHP fails > > with the following error: > > > > -- > > HTTP/1.1 200 OK > > Date: Sun, 26 Aug 2001 05:26:14 GMT > > Server: Apache/1.3.12 (Unix) (Red Hat/Linux) PHP/4.0.2 > > Connection: close > > Content-Type: text/html > > > > > > Fatal error: No content-type in POST request in Unknown on > > line 0 > > Connection closed by foreign host. > > -- > > > > The connection that the embedded system makes looks like this: > > > > -- > > POST http://host.mysite.foo/dir/phppage HTTP/1.0 > > User-Agent: ImEmbedded > > Host: host.mysite.foo > > Content-Length: 123 > > Pragma: no-cache > > Cookie: embeddedsession=myverylongsessionvariablegeneratedbythehardware > > > > > > -- > > And below is some XML stuff... > > > > I've tried setting 'Content-Type' in $HTTP_POST_VARS, using mod_rewrite in > > Apache to change the content-type (with the -T flag) and looked at all the > > options in php.ini. I'm using PHP 4.0.2 w/Apache 1.3.12 (if you couldn't > > tell from the sig above...) > > > > Nothing works correctly. The mod_rewrite trick would work, but it makes > > everthing to that URL text/xml, including the PHP script, which no longer > > executes. I look on the mailing lists here and on usenet, but I don't see > > a good solution... > > > > Anyone have any ideas? At this point, I'm thinking of re-writing my code > > in Perl or Python since there seems to be no solution to this problem. > > > > Note that it's PHP that rejects the request, not Apache. I don't see why > > a missing content-type should do this. It should just default to > > text/plain or something. > > > > Anyway, thanks for any help. > > > > Chris. > > > > -- > > chris maresca > > internet systems architect -- www.chrismaresca.com > > > > "linux, only up 138 days, because california has flaky power... " > > > > > > > > > -- chris maresca internet systems architect -- www.chrismaresca.com "linux, only up 138 days, because california has flaky power... " -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] POST without Content-Type?
On Sat, 25 Aug 2001, Rasmus Lerdorf wrote: > Well, first of all, you are using an ancient version of PHP. That message > was changed from a fatal error to a warning over a year ago. Cool. Thx. I'll upgrade. Had no good reason to until now. > And if you really want to have PHP accept non-typed POST data, it's an > obvious one-line change in main/SAPI.c Well, I grep'd the source, but did not find the origin of the error. Also, since I'm not familiar with PHP source, it would have taken me hours to find even that one line Thx. Chris. > -Rasmus > > On Sat, 25 Aug 2001, Chris Maresca wrote: > > > > > All, > > > > I've been coding a PHP page that listens for a connection from an embedded > > device (a piece of hardware) that sends a POST query to Apache (and to my > > PHP pages...). > > > > I've having a problem that I can't seem to solve. The embedded > > application does not set a Content-Type header on the POST, so PHP fails > > with the following error: > > > > -- > > HTTP/1.1 200 OK > > Date: Sun, 26 Aug 2001 05:26:14 GMT > > Server: Apache/1.3.12 (Unix) (Red Hat/Linux) PHP/4.0.2 > > Connection: close > > Content-Type: text/html > > > > > > Fatal error: No content-type in POST request in Unknown on > > line 0 > > Connection closed by foreign host. > > -- > > > > The connection that the embedded system makes looks like this: > > > > -- > > POST http://host.mysite.foo/dir/phppage HTTP/1.0 > > User-Agent: ImEmbedded > > Host: host.mysite.foo > > Content-Length: 123 > > Pragma: no-cache > > Cookie: embeddedsession=myverylongsessionvariablegeneratedbythehardware > > > > > > -- > > And below is some XML stuff... > > > > I've tried setting 'Content-Type' in $HTTP_POST_VARS, using mod_rewrite in > > Apache to change the content-type (with the -T flag) and looked at all the > > options in php.ini. I'm using PHP 4.0.2 w/Apache 1.3.12 (if you couldn't > > tell from the sig above...) > > > > Nothing works correctly. The mod_rewrite trick would work, but it makes > > everthing to that URL text/xml, including the PHP script, which no longer > > executes. I look on the mailing lists here and on usenet, but I don't see > > a good solution... > > > > Anyone have any ideas? At this point, I'm thinking of re-writing my code > > in Perl or Python since there seems to be no solution to this problem. > > > > Note that it's PHP that rejects the request, not Apache. I don't see why > > a missing content-type should do this. It should just default to > > text/plain or something. > > > > Anyway, thanks for any help. > > > > Chris. > > > > -- > > chris maresca > > internet systems architect -- www.chrismaresca.com > > > > "linux, only up 138 days, because california has flaky power... " > > > > > > > > > -- chris maresca internet systems architect -- www.chrismaresca.com "linux, only up 138 days, because california has flaky power... " -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] POST without Content-Type?
Well, first of all, you are using an ancient version of PHP. That message was changed from a fatal error to a warning over a year ago. And if you really want to have PHP accept non-typed POST data, it's an obvious one-line change in main/SAPI.c -Rasmus On Sat, 25 Aug 2001, Chris Maresca wrote: > > All, > > I've been coding a PHP page that listens for a connection from an embedded > device (a piece of hardware) that sends a POST query to Apache (and to my > PHP pages...). > > I've having a problem that I can't seem to solve. The embedded > application does not set a Content-Type header on the POST, so PHP fails > with the following error: > > -- > HTTP/1.1 200 OK > Date: Sun, 26 Aug 2001 05:26:14 GMT > Server: Apache/1.3.12 (Unix) (Red Hat/Linux) PHP/4.0.2 > Connection: close > Content-Type: text/html > > > Fatal error: No content-type in POST request in Unknown on > line 0 > Connection closed by foreign host. > -- > > The connection that the embedded system makes looks like this: > > -- > POST http://host.mysite.foo/dir/phppage HTTP/1.0 > User-Agent: ImEmbedded > Host: host.mysite.foo > Content-Length: 123 > Pragma: no-cache > Cookie: embeddedsession=myverylongsessionvariablegeneratedbythehardware > > > -- > And below is some XML stuff... > > I've tried setting 'Content-Type' in $HTTP_POST_VARS, using mod_rewrite in > Apache to change the content-type (with the -T flag) and looked at all the > options in php.ini. I'm using PHP 4.0.2 w/Apache 1.3.12 (if you couldn't > tell from the sig above...) > > Nothing works correctly. The mod_rewrite trick would work, but it makes > everthing to that URL text/xml, including the PHP script, which no longer > executes. I look on the mailing lists here and on usenet, but I don't see > a good solution... > > Anyone have any ideas? At this point, I'm thinking of re-writing my code > in Perl or Python since there seems to be no solution to this problem. > > Note that it's PHP that rejects the request, not Apache. I don't see why > a missing content-type should do this. It should just default to > text/plain or something. > > Anyway, thanks for any help. > > Chris. > > -- > chris maresca > internet systems architect -- www.chrismaresca.com > > "linux, only up 138 days, because california has flaky power... " > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] POST without Content-Type?
All, I've been coding a PHP page that listens for a connection from an embedded device (a piece of hardware) that sends a POST query to Apache (and to my PHP pages...). I've having a problem that I can't seem to solve. The embedded application does not set a Content-Type header on the POST, so PHP fails with the following error: -- HTTP/1.1 200 OK Date: Sun, 26 Aug 2001 05:26:14 GMT Server: Apache/1.3.12 (Unix) (Red Hat/Linux) PHP/4.0.2 Connection: close Content-Type: text/html Fatal error: No content-type in POST request in Unknown on line 0 Connection closed by foreign host. -- The connection that the embedded system makes looks like this: -- POST http://host.mysite.foo/dir/phppage HTTP/1.0 User-Agent: ImEmbedded Host: host.mysite.foo Content-Length: 123 Pragma: no-cache Cookie: embeddedsession=myverylongsessionvariablegeneratedbythehardware -- And below is some XML stuff... I've tried setting 'Content-Type' in $HTTP_POST_VARS, using mod_rewrite in Apache to change the content-type (with the -T flag) and looked at all the options in php.ini. I'm using PHP 4.0.2 w/Apache 1.3.12 (if you couldn't tell from the sig above...) Nothing works correctly. The mod_rewrite trick would work, but it makes everthing to that URL text/xml, including the PHP script, which no longer executes. I look on the mailing lists here and on usenet, but I don't see a good solution... Anyone have any ideas? At this point, I'm thinking of re-writing my code in Perl or Python since there seems to be no solution to this problem. Note that it's PHP that rejects the request, not Apache. I don't see why a missing content-type should do this. It should just default to text/plain or something. Anyway, thanks for any help. Chris. -- chris maresca internet systems architect -- www.chrismaresca.com "linux, only up 138 days, because california has flaky power... " -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]