I am trying to find a way to get all http request headers that a browser send when requestion one of my pages.

$_SERVER and apache_request_headers() doesn't help in this: they show me not all request headers.

For example, if I go to a web page of my website, using firefox's Live http headers component, I see that my request header is something like:

http://www.myurl.com/path/

GET /path/ HTTP/1.1
Host: www.myurl.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; it; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
etc.

what I am interested in and that I cannot get is the row:

GET /path/ HTTP/1.1

that when a page is requested by a proxy becomes:

GET http://www.myurl.com/path/ HTTP/1.1

Is there any way to get this header using PHP?

Thanks!

    fabiuz;10960263 wrote:

    what I am interested in and that I cannot get is the row:

    GET /path/ HTTP/1.1

    that when a page is requested by a proxy becomes:

    GET http://www.myurl.com/path/ HTTP/1.1

    Is there any way to get this header using PHP?

    Sure!

    echo "$_SERVER[REQUEST_METHOD] $_SERVER[REQUEST_URI] $_SERVER[REQUEST_PROTOCOL]";

      unfortunately not :-(

      This will report me the same row when using proxy and when not using them.
      So I always get:

      GET /path/ HTTP/1.1

      and never:

      GET http://www.myurl.com/path/ HTTP/1.1

      that is what I am looking for to detect possible proxyes.

      Thanks

        The above code worked as expected for me when I used an absolute URI.

          mhm, what do you mean "when I use an absolute uri"?

          I have placed such code in one php page, then I have opened Firefox, configured a proxy for the connection and tried to open:

          http://www.myurl.com/proxy.php

          what I get is:

          GET /proxy.php

          while I was looking for the full url, like I could see in the live headers from other tools.

          What could be wrong?

            fabiuz;10960287 wrote:

            mhm, what do you mean "when I use an absolute uri"?

            I mean I used "GET http://localhost/test.php HTTP/1.1" and observed the correct response.

            fabiuz wrote:

            What could be wrong?

            One problem I can think of is that you seem to have the assumption that all proxies behave this way.

              the last statement should be "SERVER_PROTOCOL" instead of "REQUEST_PROTOCOL" isn't it?

              Anyway REQUEST_URI seems not to provide the real URI in the get request.

                fabiuz;10960291 wrote:

                the last statement should be "SERVER_PROTOCOL" instead of "REQUEST_PROTOCOL" isn't it?

                Ah yes, that was a typo - my bad.

                fabiuz;10960291 wrote:

                Anyway REQUEST_URI seems not to provide the real URI in the get request.

                It does for me on PHP 5.3.2, and I doubt that's changed in a long time.

                  Write a Reply...