Here's a rather advanced question (a presume since I've searche dfor the past 4 hours for the answer)

I need the ability (in apache 1.3.20) to TOTALLY suppress the headers. That's not it.. I need to take it a step further.

I would like the server to IMMEDIATELY send HTML (or text.. whatever) I specify upon detecting an "incomming" connection on port 80 (or whatever port I have it listening to)

Any way of doing this (well.. I'm sure there is, but any way that you guys and gals know of)?

Thanks

Phantazm

    10 days later

    Interesting question this . . . but I think that headers are needed by browsers rendering engines to know which kind of document they are receiving.

    Here's a snapshot of the headers sent by the www.phpbuilder.com server

    HTTP/1.0 200 OK
    Date: Mon, 13 Jan 2003 10:20:06 GMT
    Server: Apache/1.3.26 (Unix) PHP/4.1.2 mod_oas/5.1.2 mod_cap/1.0
    X-Powered-By: PHP/4.1.2
    Content-Length: 27302
    Content-Type: text/html
    X-Cache: MISS from Linux.Proxy.ums.it
    Proxy-Connection: keep-alive
    X-Forwarded-For: yahoo.com, microsoft.com, netscape.com, aol.com, [url]www.phpbuilder.com[/url]
    <start> 27: Kill pop-up windows
    <start> 27: Suppress all JavaScript errors
    <start> 27: Stop browser window resizing
    BlockList 28: in AdList, line 78
    

    as you can see there were many info as server version content length and Content-Type that are required by a browser.

    I don't know what do you want to do exactly.

    You can find out more here: http://httpd.apache.org/docs/mod/mod_headers.html

    Hope this helps 🙂

      I am not a world authority on headers, but I have spent a lot of time reading the W3C documents on http headers and I don't see many situations where it would be useful to suppress 'standard' headers.

      If you are wanting to send this HTML straight to a web browser then you need those headers to let the browser understand what is receiving.

      If you were making the request using some custom-made application which does not need headers then maybe there would be some point. But a browser needs a certain amount of header to make things work.

      Maybe if you explained your loathing of headers then it would be easier to understand your question.

      DaveTshave

        3 years later

        ok, but lets say you WERE setting up a custom made app, say, something that took input in the form of get requests, but wanted to spit back out just a simple 01 ok or 02 you've got an error, and didn't want to spit back something big like, for example:

        HTTP/1.1 200 OK
        Date: Wed, 11 Jan 2006 18:16:04 GMT
        Server: Apache/1.3.33 (Darwin) mod_ssl/2.8.22 OpenSSL/0.9.7g PHP/5.0.4
        Cache-Control: max-age=60
        Expires: Wed, 11 Jan 2006 18:17:04 GMT
        X-Powered-By: PHP/5.0.4
        Connection: close
        Transfer-Encoding: chunked
        Content-Type: text/html

        2

        ok

        just to say "ok", which is going to be read by a computer anyway, how would one turn off the headers?

        Thanks 🙂

        -- James

          Have you looked at mod_headers?

          Keep in mind though that if your planning on using HTTP1.1 certain rules need to be followed. For instance, the HOST header is required to be sent in a request, if a server does not recieve this header it must return a "400 Bad Request".

          say, something that took input in the form of get requests, but wanted to spit back out just a simple 01 ok or 02 you've got an error

          This sounds to me like your talking about a custom client rather than customising the server headers. A web browser would spit it if you give it the wrong headers.

          What exactly are you trying to do? Its easy enough to write your own server/client if thats what you need, instead of trying to bend http into something it is'nt.

            4 months later

            Funny.. I started this thread over three years ago.. and yes, it was for developing a custom client-side applicaiton. I wanted my PHP script to be able to send a RAW response back to my client app, but have it handled as a usual HTTP request. (Make any sense.. hope I explained that right...)

            Anyway, I'll dig up some code and post as soon as I can. Funny I tripped over my own thread that's three years old! 😛

              24 days later

              hi phantazm ... did you find a solution how to suppress or replace the http headers? i am trying to set up a audio streaming application with the HTTP/ICY protocol ...

              i was trying to set the headers like this:

                  header("ICY 200 OK");
                  header("icy-notice1:<BR>This stream requires <a href=\"http://www.winamp.com/\">Winamp</a><BR>");
                  header("icy-notice2:Smaaps Musicbox Audio Server PHP<BR>");
                  header("icy-name:Smaaps Best of Radio");
                  header("icy-genre: Best of Musicbox");
                  header("icy-url:http://music.dyndns.org");
                  header("content-type:audio/mpeg");
                  header("icy-pub:1");
                  header("icy-metaint:0"); //32768
                  header("icy-br:192");

              But either Apacher or PHP always replace the "ICY 200 OK" header with "HTTP/1.1 200 OK" and add other headers such as Server und X-Powered. Is there any way to avoid this?

              I was also trying to open a socket to the requesting application. But that also fails. I think the applications (browser or winamp) only accepts the response from the port they were requesting (wich was 80 and is used by apache).

                  $fp = fsockopen($_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], $errno, $errstr, 12);
              
                  fputs($fp, "ICY 200 OK\r\n");
                  fputs($fp, "icy-notice1:<BR>This stream requires <a href=\"http://www.winamp.com/\">Winamp</a><BR>\r\n");
                  fputs($fp, "icy-notice2:Smaaps Musicbox Audio Server PHP<BR>\r\n");
                  fputs($fp, "icy-name:Smaaps Best of Radio\r\n");
                  fputs($fp, "icy-genre: Best of Musicbox\r\n");
                  fputs($fp, "icy-url:http://music.dyndns.org\r\n");
                  fputs($fp, "content-type:audio/mpeg\r\n");
                  fputs($fp, "icy-pub:1\r\n");
                  fputs($fp, "icy-metaint:32768\r\n");
                  fputs($fp, "icy-br:192\r\n\r\n");

              Any ideas how to solve this problem?

                You're trying to get Apache to respond to a HTTP request with a non-HTTP response. It won't do this, as it's a HTTP server, which always tries to speak HTTP correctly.

                Consider using an alternative web server, or look for an Apache2 module which implements this alternative protocol.

                You can probably forget using PHP anyway.

                Mark

                  Write a Reply...