views:

69

answers:

3

How if at all can I strip all the header from a PHP response through apache in order to just stream the text response. I've tried adding a custom htaccess but to no avail. I've got limited control of the hosting server. The stream is read by an embedded device which doesn't need any headers.

A: 

There is a PHP function called header_remove(). I never used it before but you can try if this works for you. Note that this function is available since PHP 5.3.0.

elusive
Therein lies the problem. My hosting is only PHP 5.2.9. thus header_remove() does not work... AAAAHH!
Jan de Jager
You already tried [this directive](http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header), right?
elusive
Sorry pal you understand as little as the OP does
Col. Shrapnel
@elusive yip, no joy. Doesn't remove anything, as most of the headers are added by apache, and the .htaccess also doesn't do much. any further suggestions?
Jan de Jager
If you are not allowed to manipulate headers using the webservers configuration, i doubt that there is any other way to achieve this. You should probably take a look at sockets, like suggested.
elusive
+1  A: 

It get's to a point where certain headers are NEEDED to be interpreted by the browser so it can render the output. If the reason why you want to remove the header is for a chat-like feature, think about using a persitant keep-alive connection

Tips in reducing bandwidth

  1. Use ajax: keep the response from PHP in JSON format and update DOM elements

  2. Gzip.

  3. Just don't worry about headers -- typically a HTTP OK response will only take up < 200 bytes, hardly anything in comparison to the actual page content. Focus on where it really matters.

Edit:

To suit your case look into using sockets (UDP would be a good option if wanting to cut back on a lot of bandwidth) socket_listen() (non UDP) or socket_bind() capabable of UDP

Gary Green
The response is not read by a browser, so headers are not needed at all. 200 bytes at this point iss too much, only have 1280 bytes to work with and the data is 1024 bytes...
Jan de Jager
I've updated my response, would be a good idea to add that requirement in your question :)
Gary Green
Sweet, thanks for the help. Everyone else kan go to hell. I've asked for help not criticism.
Jan de Jager
@Jan well it is not a paid support service but an enthusiast site. And if you do not like responses you can go the same way lol :)
Col. Shrapnel
+1  A: 

That's impossible.
You are using HTTP protocol and HTTP protocol response always contains headers.
Either do not use HTTP or teach your device to strip headers. It's not that hard.

Anyway, php has very little to do with removing headers. There is also a web-server that actually interacts with your device and taught to send proper headers.

Col. Shrapnel