RE: [PHP] How to suppress HTTP headers?

2005-08-18 Thread Richard Lynch
On Tue, August 16, 2005 10:02 am, [EMAIL PROTECTED] wrote:
 BTW: I made a mistake last time. Apparently with CLI there are
 headers.  You can use php -q to suppress headers when using PHP via

CGI has always sent out at least one header.
Content-type: text/html
-q has always suppressed that.

CLI may or may not have sent headers...

 CLI.  Odd.  Not sure I had to do that when I wrote a few CLI scripts
 before.  Oh well, something to play with another day (don't have time
 to check it right now).

 So another thing I may be wrong on.. but a thought..  If you use the
 header() command, does it prevent the web server from generating it's
 own headers?

I believe your header() commands only REPLACE any headers PHP would
have sent, but any other headers it's gonna send, it's still gonna
send them.

 That is, if you send out htmlbodySomething/body/html does the
 web server automatically generate the headers but if you use header()
 it uses what PHP generates rather than it's own?

 If so.. can you just do:
 header();

 With nothing in it to suppress headers?

I think that will suppress headers... by issuing an ERROR that a
required argument is missing :-)

 Or can you do something like:

 header(xmlstuff/xml);

No.

That is not a valid header, for starters.

You MIGHT be able to wipe out the headers PHP sends by doing
something like:

header(Content-type:); //Wipe out Content-type:

but I wouldn't cound on it.

Sounds to me like the remote server isn't actually using HTTP at all.

HTTP without headers is just not HTTP.

You may want to write your own server in PHP using sockets -- but
then you'll need to convince the remote server to connect/use that
different server you have written.  Either connecting on a different
port, or to a different domain, or a different URL (maybe) so you can
configure your box to use your server for these weird requests.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to suppress HTTP headers?

2005-08-18 Thread Thomas Capote
Just to catch up:

I'm trying to respond to a HTTP POST request without sending any HTTP
headers with the response (that is, reply with *content only*).

1) The CGI SAPI will always send some basic headers with any script output;
these include the status line ('HTTP/1.1 200 OK'), 'Content-type:', 'Date:'
and 'Content-length:'.

2) While the 'q' switch (php -q) is necessary and sufficient to suppress
HTTP header generation using the CLI ('command line interface'), it is not
clear to me how to apply this switch in a CGI configuration. Any ideas?

3) The header() command inserts or replaces headers to be sent by PHP.
However, header() (with no arguments) does not suppress header output, it
simply generates an error. Even if something like header('Content-type:')
suppressed the 'Content-type' header, how would we suppress all header
output including the status line ('HTTP/1.1 200 OK')?

4) Trying to use fsockopen() from the script receiving the POST request
fails because the client won't accept a redundant connection on the same
port/address it is currently using to issue the original POST request (it is
waiting for a response).

5) Mr. Lynch is right: this is NOT an HTTP compliant exchange. This is a bug
in the client machine that cannot be fixed (by me), but must be worked
around somehow.

6) All header information must be suppressed. That includes the status line,
too.

Tough little problem, eh guys?

I see three possible avenues to a solution.

1) Find some PHP command that will suppress header generation, or simply
circumvent it, if only as a side-effect.

2) Get Apache to not send headers for this page, maybe through SSI
directives, .htaccess file, or some other mechanism.

3) Write my own mini-server (to listen on port 6237 or something) to handle
these requests using socket calls in PERL, Java, or even the PHP CLI. I'm
not sure I could pull off programming something robust enough, frankly. I'd
rather hijack Apache to do the heavy lifting.

I'm not an expert in any of this, which is why I appreciate all the help I'm
getting. Thanks.


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 18, 2005 3:48 AM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: RE: [PHP] How to suppress HTTP headers?

On Tue, August 16, 2005 10:02 am, [EMAIL PROTECTED] wrote:
 BTW: I made a mistake last time. Apparently with CLI there are
 headers.  You can use php -q to suppress headers when using PHP via

CGI has always sent out at least one header.
Content-type: text/html
-q has always suppressed that.

CLI may or may not have sent headers...

 CLI.  Odd.  Not sure I had to do that when I wrote a few CLI scripts
 before.  Oh well, something to play with another day (don't have time
 to check it right now).

 So another thing I may be wrong on.. but a thought..  If you use the
 header() command, does it prevent the web server from generating it's
 own headers?

I believe your header() commands only REPLACE any headers PHP would
have sent, but any other headers it's gonna send, it's still gonna
send them.

 That is, if you send out htmlbodySomething/body/html does the
 web server automatically generate the headers but if you use header()
 it uses what PHP generates rather than it's own?

 If so.. can you just do:
 header();

 With nothing in it to suppress headers?

I think that will suppress headers... by issuing an ERROR that a
required argument is missing :-)

 Or can you do something like:

 header(xmlstuff/xml);

No.

That is not a valid header, for starters.

You MIGHT be able to wipe out the headers PHP sends by doing
something like:

header(Content-type:); //Wipe out Content-type:

but I wouldn't cound on it.

Sounds to me like the remote server isn't actually using HTTP at all.

HTTP without headers is just not HTTP.

You may want to write your own server in PHP using sockets -- but
then you'll need to convince the remote server to connect/use that
different server you have written.  Either connecting on a different
port, or to a different domain, or a different URL (maybe) so you can
configure your box to use your server for these weird requests.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-18 Thread Chris Shiflett

Hi Thomas,


I'm trying to respond to a HTTP POST request without sending any HTTP
headers with the response (that is, reply with *content only*).


This is really strange problem. :-)

I don't know the answer, but I am pretty confident that you're not going 
to be able to eliminate headers through your PHP code. This is a 
question that an Apache expert might have a solution to, although I'd be 
surprised if you could force Apache to misbehave, which is exactly what 
you're wanting.


I think your solution is going to wind up being to write your own web 
server that does not correctly adhere to the protocol, because I doubt 
you'll find existing software to do this.


There is a web server written in PHP (odd, I know), that you can 
possibly hack to eliminate the HTTP header output. It's called Nanoweb:


http://nanoweb.si.kz/

Hope that helps. Let us know how it goes. :-)

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-18 Thread comex
 2) While the 'q' switch (php -q) is necessary and sufficient to suppress
 HTTP header generation using the CLI ('command line interface'), it is not
 clear to me how to apply this switch in a CGI configuration. Any ideas?
I believe that switch works on CGI, and that in CLI headers are
surpressed by default.

$ php-cgi
test
Content-type: text/html
X-Powered-By: PHP/4.3.10-15

test

$ php
test
test

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-18 Thread Matthew Weier O'Phinney
* Thomas Capote [EMAIL PROTECTED]:
 3) The header() command inserts or replaces headers to be sent by PHP.
 However, header() (with no arguments) does not suppress header output, it
 simply generates an error. Even if something like header('Content-type:')
 suppressed the 'Content-type' header, how would we suppress all header
 output including the status line ('HTTP/1.1 200 OK')?

The HTTP/1.1 200 OK is a header sent by your web server; PHP has NO
control over headers sent by the web server -- only those that PHP
appends to them.

 5) Mr. Lynch is right: this is NOT an HTTP compliant exchange. This is a bug
 in the client machine that cannot be fixed (by me), but must be worked
 around somehow.

This is the real nut of the problem.

 Tough little problem, eh guys?

 I see three possible avenues to a solution.

 1) Find some PHP command that will suppress header generation, or simply
 circumvent it, if only as a side-effect.

Already noted, cano't be done.

 2) Get Apache to not send headers for this page, maybe through SSI
 directives, .htaccess file, or some other mechanism.

I don't think there's a way to do this -- HTTP headers are part of the
HTTP protocol, and that's what Apache tries to implement. But I can't
say with 100% certainty that someone hasn't done it. Search on the
apache web site.

 3) Write my own mini-server (to listen on port 6237 or something) to handle
 these requests using socket calls in PERL, Java, or even the PHP CLI. I'm
 not sure I could pull off programming something robust enough, frankly. I'd
 rather hijack Apache to do the heavy lifting.

I think this is likely to be the direction you'll need to go. This sort
of thing actually isn't too difficult to do -- I've used and tinkered on
PHP chat server implementations that do similar things. Perl has a
wealth of tools for creating net servers which, again, make this stuff
fairly trivial.

Good luck!

 -Original Message-
 From: Richard Lynch [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, August 18, 2005 3:48 AM
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net; [EMAIL PROTECTED]
 Subject: RE: [PHP] How to suppress HTTP headers?

 On Tue, August 16, 2005 10:02 am, [EMAIL PROTECTED] wrote:
 BTW: I made a mistake last time. Apparently with CLI there are
 headers.  You can use php -q to suppress headers when using PHP via

 CGI has always sent out at least one header.
 Content-type: text/html
 -q has always suppressed that.

 CLI may or may not have sent headers...

 CLI.  Odd.  Not sure I had to do that when I wrote a few CLI scripts
 before.  Oh well, something to play with another day (don't have time
 to check it right now).
 
 So another thing I may be wrong on.. but a thought..  If you use the
 header() command, does it prevent the web server from generating it's
 own headers?

 I believe your header() commands only REPLACE any headers PHP would
 have sent, but any other headers it's gonna send, it's still gonna
 send them.

 That is, if you send out htmlbodySomething/body/html does the
 web server automatically generate the headers but if you use header()
 it uses what PHP generates rather than it's own?
 
 If so.. can you just do:
 header();
 
 With nothing in it to suppress headers?

 I think that will suppress headers... by issuing an ERROR that a
 required argument is missing :-)

 Or can you do something like:
 
 header(xmlstuff/xml);

 No.

 That is not a valid header, for starters.

 You MIGHT be able to wipe out the headers PHP sends by doing
 something like:

 header(Content-type:); //Wipe out Content-type:

 but I wouldn't cound on it.

 Sounds to me like the remote server isn't actually using HTTP at all.

 HTTP without headers is just not HTTP.

 You may want to write your own server in PHP using sockets -- but
 then you'll need to convince the remote server to connect/use that
 different server you have written.  Either connecting on a different
 port, or to a different domain, or a different URL (maybe) so you can
 configure your box to use your server for these weird requests.



-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to suppress HTTP headers?

2005-08-16 Thread Thomas Capote
I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though the CGI SAPI provides a way to
suppress HTTP headers, there's no equivalent switch to enable them in the
CLI SAPI. How would one suppress HTTP headers, as noted above, in the CGI
SAPI for a particular page on my site?
 
Somebody, please help.
--TC.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-16 Thread tg-php
So their page POSTs to a PHP page that you've created?  I'm not seeing where 
headers come into play there, they're on output, not input.  Maybe I just 
stayed up too late last night, but I'm having trouble wrapping my brain around 
the problem.

One thing I did notice was you mentioned switches for CGI vs CLI SAPI.  I 
expect that there wouldn't be a switch for CLI because no headers are needed 
when using PHP command line, therefore nothing to turn off.  Again, maybe I'm 
misunderstanding the situation but thought I'd throw that thought in the ring.

Maybe you can describe the interaction between the system you can't control and 
your PHP scripts better.  Walk us through it step by step.

-TG

= = = Original message = = =

I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though the CGI SAPI provides a way to
suppress HTTP headers, there's no equivalent switch to enable them in the
CLI SAPI. How would one suppress HTTP headers, as noted above, in the CGI
SAPI for a particular page on my site?
 
Somebody, please help.
--TC.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to suppress HTTP headers?

2005-08-16 Thread Thomas Capote
I knew my description was a bit mangled; I was trying to keep it short.
Sorry. Take two:

A remote server is sending event records to my server using HTTP POST
requests to http://my.server.com/storeit.php, let's say. The remote server
expects acknowledgement by way of a response to its request. My script
(storeit.php) must respond like it would any other page request over HTTP;
it simply uses echo/print to produce a response.

This would work fine EXCEPT that the remote server is *badly* written. Its
flaw? The HTTP headers included in my response trip it up. For some reason,
it expects just the *contents* of the response, without headers.

Here's a mock up of the current situation:

  ---Received from remote server
  HTTP/1.0 storeit.php POST
  Content-Type: text/xml
  Content-Length: 35
  Host: 11.11.11.11

  DATA
KEYvalue/KEY
  /DATA

  --- Reply sent to remote server 
  HTTP/1.0 200 OK
  Content-Type: text/xml
  Content-Length: 34
  Host: 22.22.22.22

  ACK
ERROR0/ERROR
  /ACK


What the reply needs to look like is:

  --- Reply sent to remote server 
  ACK
ERROR0/ERROR
  /ACK


No headers.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 16, 2005 11:00 AM
To: php-general@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to suppress HTTP headers?

So their page POSTs to a PHP page that you've created?  I'm not seeing where
headers come into play there, they're on output, not input.  Maybe I just
stayed up too late last night, but I'm having trouble wrapping my brain
around the problem.

One thing I did notice was you mentioned switches for CGI vs CLI SAPI.  I
expect that there wouldn't be a switch for CLI because no headers are needed
when using PHP command line, therefore nothing to turn off.  Again, maybe
I'm misunderstanding the situation but thought I'd throw that thought in the
ring.

Maybe you can describe the interaction between the system you can't control
and your PHP scripts better.  Walk us through it step by step.

-TG

= = = Original message = = =

I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though the CGI SAPI provides a way to
suppress HTTP headers, there's no equivalent switch to enable them in the
CLI SAPI. How would one suppress HTTP headers, as noted above, in the CGI
SAPI for a particular page on my site?
 
Somebody, please help.
--TC.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to suppress HTTP headers?

2005-08-16 Thread tg-php
BTW: I made a mistake last time. Apparently with CLI there are headers.  You 
can use php -q to suppress headers when using PHP via CLI.  Odd.  Not sure I 
had to do that when I wrote a few CLI scripts before.  Oh well, something to 
play with another day (don't have time to check it right now).

So another thing I may be wrong on.. but a thought..  If you use the header() 
command, does it prevent the web server from generating it's own headers?

That is, if you send out htmlbodySomething/body/html does the web 
server automatically generate the headers but if you use header() it uses what 
PHP generates rather than it's own?

If so.. can you just do:
header();

With nothing in it to suppress headers?

Or can you do something like:

header(xmlstuff/xml);

?

Just thinking out loud since nobody else has responded yet :)

-TG

= = = Original message = = =

I knew my description was a bit mangled; I was trying to keep it short.
Sorry. Take two:

A remote server is sending event records to my server using HTTP POST
requests to http://my.server.com/storeit.php, let's say. The remote server
expects acknowledgement by way of a response to its request. My script
(storeit.php) must respond like it would any other page request over HTTP;
it simply uses echo/print to produce a response.

This would work fine EXCEPT that the remote server is *badly* written. Its
flaw? The HTTP headers included in my response trip it up. For some reason,
it expects just the *contents* of the response, without headers.

Here's a mock up of the current situation:

  ---Received from remote server
  HTTP/1.0 storeit.php POST
  Content-Type: text/xml
  Content-Length: 35
  Host: 11.11.11.11

  DATA
KEYvalue/KEY
  /DATA

  --- Reply sent to remote server 
  HTTP/1.0 200 OK
  Content-Type: text/xml
  Content-Length: 34
  Host: 22.22.22.22

  ACK
ERROR0/ERROR
  /ACK


What the reply needs to look like is:

  --- Reply sent to remote server 
  ACK
ERROR0/ERROR
  /ACK


No headers.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 16, 2005 11:00 AM
To: php-general@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to suppress HTTP headers?

So their page POSTs to a PHP page that you've created?  I'm not seeing where
headers come into play there, they're on output, not input.  Maybe I just
stayed up too late last night, but I'm having trouble wrapping my brain
around the problem.

One thing I did notice was you mentioned switches for CGI vs CLI SAPI.  I
expect that there wouldn't be a switch for CLI because no headers are needed
when using PHP command line, therefore nothing to turn off.  Again, maybe
I'm misunderstanding the situation but thought I'd throw that thought in the
ring.

Maybe you can describe the interaction between the system you can't control
and your PHP scripts better.  Walk us through it step by step.

-TG

= = = Original message = = =

I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though the CGI SAPI provides a way to
suppress HTTP headers, there's no equivalent switch to enable them in the
CLI SAPI. How would one suppress HTTP headers, as noted above, in the CGI
SAPI for a particular page on my site?
 
Somebody, please help.
--TC.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-16 Thread Kristen G. Thorson

Or use sockets...

http://us3.php.net/manual/en/function.fsockopen.php

Just don't send any HTTP headers.


kgt


[EMAIL PROTECTED] wrote:


BTW: I made a mistake last time. Apparently with CLI there are headers.  You can use 
php -q to suppress headers when using PHP via CLI.  Odd.  Not sure I had to 
do that when I wrote a few CLI scripts before.  Oh well, something to play with another 
day (don't have time to check it right now).

So another thing I may be wrong on.. but a thought..  If you use the header() 
command, does it prevent the web server from generating it's own headers?

That is, if you send out htmlbodySomething/body/html does the web 
server automatically generate the headers but if you use header() it uses what PHP generates rather than it's 
own?

If so.. can you just do:
header();

With nothing in it to suppress headers?

Or can you do something like:

header(xmlstuff/xml);

?

Just thinking out loud since nobody else has responded yet :)

-TG

= = = Original message = = =

I knew my description was a bit mangled; I was trying to keep it short.
Sorry. Take two:

A remote server is sending event records to my server using HTTP POST
requests to http://my.server.com/storeit.php, let's say. The remote server
expects acknowledgement by way of a response to its request. My script
(storeit.php) must respond like it would any other page request over HTTP;
it simply uses echo/print to produce a response.

This would work fine EXCEPT that the remote server is *badly* written. Its
flaw? The HTTP headers included in my response trip it up. For some reason,
it expects just the *contents* of the response, without headers.

Here's a mock up of the current situation:

 ---Received from remote server
 HTTP/1.0 storeit.php POST
 Content-Type: text/xml
 Content-Length: 35
 Host: 11.11.11.11

 DATA
   KEYvalue/KEY
 /DATA

 --- Reply sent to remote server 
 HTTP/1.0 200 OK

 Content-Type: text/xml
 Content-Length: 34
 Host: 22.22.22.22

 ACK
   ERROR0/ERROR
 /ACK


What the reply needs to look like is:

 --- Reply sent to remote server 
 ACK

   ERROR0/ERROR
 /ACK


No headers.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 16, 2005 11:00 AM

To: php-general@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to suppress HTTP headers?

So their page POSTs to a PHP page that you've created?  I'm not seeing where
headers come into play there, they're on output, not input.  Maybe I just
stayed up too late last night, but I'm having trouble wrapping my brain
around the problem.

One thing I did notice was you mentioned switches for CGI vs CLI SAPI.  I
expect that there wouldn't be a switch for CLI because no headers are needed
when using PHP command line, therefore nothing to turn off.  Again, maybe
I'm misunderstanding the situation but thought I'd throw that thought in the
ring.

Maybe you can describe the interaction between the system you can't control
and your PHP scripts better.  Walk us through it step by step.

-TG

= = = Original message = = =

I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though the CGI SAPI provides a way to
suppress HTTP headers, there's no equivalent switch to enable them in the
CLI SAPI. How would one suppress HTTP headers, as noted above, in the CGI
SAPI for a particular page on my site?

Somebody, please help.
--TC.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to suppress HTTP headers?

2005-08-16 Thread tg-php
hah.. I should have mentioned this as well, but my brain is absorbed in...  
sockets... and xml..  and sending headers manually via fputs..   nothing 
relative to this discussion at all..  hah..

?php

$_XML_DATA = xmlGoesHere/xmlGoesHere\r\n;

$_FULL_XML_REQUEST  = ?xml version=\1.0\ encoding=\UTF-8\?\r\n;
$_FULL_XML_REQUEST .= !DOCTYPE REQUEST_GROUP SYSTEM \SomeXMLdtd.dtd\\r\n;
$_FULL_XML_REQUEST .= $_XML_DATA;
  
$_XML_REQUEST_HEADER  = POST /path/to/script.php HTTP/1.1\r\n;
$_XML_REQUEST_HEADER .= Host: my.server.com\r\n;
$_XML_REQUEST_HEADER .= Content-type: application/x-www-form-urlencoded\r\n;
$_XML_REQUEST_HEADER .= Content-length:  . strlen($_FULL_XML_REQUEST) . 
\r\n;
$_XML_REQUEST_HEADER .= Connection: close\r\n\r\n;

$fp = fsockopen(my.server.com, 80, $_FSOCK_ERR_NUMBER, $_FSOCK_ERR_MESSAGE, 
100);
  ~
if(!$fp){
  exit(Failed to open socket...);
}

if (fputs($fp, $_XML_REQUEST_HEADER . $_FULL_XML_REQUEST) === FALSE) {
  exit(Failed to send request...);
}

while(!feof($fp)){
  ~  
  // @ error suppression used on fgets() due to bug in PHP that reports the 
following waring:
  // Warning: fgets(): SSL: fatal protocol error in 
/var/www/secure/dev2/panda/DevTools/LandsafeTest/index.php on line 
  // No good solution found online, most people adjust their error reporting to 
ignore warnings (sloppy!)
  $tmp = @fgets($fp, 4096);
  
  $_XML_RESPONSE .= $tmp;
}
echo pre\n;
echo $_XML_RESPONSE;
  
fclose($fp);
?


= = = Original message = = =

Or use sockets...

http://us3.php.net/manual/en/function.fsockopen.php

Just don't send any HTTP headers.


kgt


[EMAIL PROTECTED] wrote:

BTW: I made a mistake last time. Apparently with CLI there are headers.  You 
can use php -q to suppress headers when using PHP via CLI.  Odd.  Not sure I 
had to do that when I wrote a few CLI scripts before.  Oh well, something to 
play with another day (don't have time to check it right now).

So another thing I may be wrong on.. but a thought..  If you use the header() 
command, does it prevent the web server from generating it's own headers?

That is, if you send out htmlbodySomething/body/html does the web 
server automatically generate the headers but if you use header() it uses what 
PHP generates rather than it's own?

If so.. can you just do:
header();

With nothing in it to suppress headers?

Or can you do something like:

header(xmlstuff/xml);

?

Just thinking out loud since nobody else has responded yet :)

-TG

= = = Original message = = =

I knew my description was a bit mangled; I was trying to keep it short.
Sorry. Take two:

A remote server is sending event records to my server using HTTP POST
requests to http://my.server.com/storeit.php, let's say. The remote server
expects acknowledgement by way of a response to its request. My script
(storeit.php) must respond like it would any other page request over HTTP;
it simply uses echo/print to produce a response.

This would work fine EXCEPT that the remote server is *badly* written. Its
flaw? The HTTP headers included in my response trip it up. For some reason,
it expects just the *contents* of the response, without headers.

Here's a mock up of the current situation:

  ---Received from remote server
  HTTP/1.0 storeit.php POST
  Content-Type: text/xml
  Content-Length: 35
  Host: 11.11.11.11

  DATA
KEYvalue/KEY
  /DATA

  --- Reply sent to remote server 
  HTTP/1.0 200 OK
  Content-Type: text/xml
  Content-Length: 34
  Host: 22.22.22.22

  ACK
ERROR0/ERROR
  /ACK


What the reply needs to look like is:

  --- Reply sent to remote server 
  ACK
ERROR0/ERROR
  /ACK


No headers.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 16, 2005 11:00 AM
To: php-general@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to suppress HTTP headers?

So their page POSTs to a PHP page that you've created?  I'm not seeing where
headers come into play there, they're on output, not input.  Maybe I just
stayed up too late last night, but I'm having trouble wrapping my brain
around the problem.

One thing I did notice was you mentioned switches for CGI vs CLI SAPI.  I
expect that there wouldn't be a switch for CLI because no headers are needed
when using PHP command line, therefore nothing to turn off.  Again, maybe
I'm misunderstanding the situation but thought I'd throw that thought in the
ring.

Maybe you can describe the interaction between the system you can't control
and your PHP scripts better.  Walk us through it step by step.

-TG

= = = Original message = = =

I am coding a PHP page to deal with a badly implemented automated status
update script on a remote server (that I do not control) which fails if my
response to it's POST request has HTTP headers. Go figure. So the question
is How do I NOT send HTTP headers in my response? or How can my script
suppress headers completely? Whatever the solution, it should affect only
this page/script.

In chapter 43, the PHP Manual states: Though