You are here: Re: [PHP] How to suppress HTTP headers? « PHP « IT news, forums, messages
Re: [PHP] How to suppress HTTP headers?

Posted by Matthew Weier O'Phinney on 10/20/17 11:24

* "Thomas Capote" <thomascapote@onlinenetworks.com>:
> 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:ceo@l-i-e.com]
> Sent: Thursday, August 18, 2005 3:48 AM
> To: tg-php@gryffyndevelopment.com
> Cc: php-general@lists.php.net; thomascapote@onlinenetworks.com
> Subject: RE: [PHP] How to suppress HTTP headers?
>
> On Tue, August 16, 2005 10:02 am, tg-php@gryffyndevelopment.com 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 "<html><body>Something</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("<xml>stuff</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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация