A GREAT SUGGESTION TO PHP DEVELOPPERS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Wellesz

    A GREAT SUGGESTION TO PHP DEVELOPPERS

    Hello,

    It would be great if there was an option to tell PHP to let the user
    manage all the HTTP headers instead of sending what it thinks is good for
    the programmer...

    For example when you write:

    header("Status: 200 OK");
    header("Locatio n: /my_internal_red irected_page.ph p");

    PHP "decides" that the status will be "302 moved", ignoring the "Status:
    200 OK" (ie: the programmer is stupid)...

    I use PHP as a cgi along with mod_fastcgi, when fastcgi sees a relative
    redirection with a "200 OK" status it autaumatically do an internal
    redirection (very useful in some cases, to hide a file url for example).

    Well, in PHP 4.3.4, the only way I found to achieve this was this
    wonderful trick:

    header("Locatio n: /my_internal_red irected_page.ph p");
    header("HTTP/1.0 200 OK");

    If you put the Location header after the "HTTP/1.0 200 OK" header PHP
    sends a 302 status without the Location header (no comment).

    That reminds me Micro$oft programs that always know better what the user
    wants to do than the user himself...

    It is a pity which PHP behaves like micro$oft, if the programmer sends
    stupid HTTP headers, PHP should let him do...

    So I think that an option to let the programmer send all http headers
    would be great, that way people who don't want to care about headers
    won't have troubles and experimented programmers will be happy :)


    I would like to thank all PHP developpers for their great work and I hope
    they'll consider this suggestion ;)




    John


    PS: I posted this suggestion here because I don't know where to send
    it... If someone knows a better place, please tell me.
  • Savut

    #2
    Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

    I dont approuve your suggestion because right now, it send the correct
    header fallowing what you are doing with the http header. Exemple, if you
    moved a file permanently and you send a 200 OK, we whould be in a world of
    mess. It's like you are connecting to a ftp server but want to fake him as
    you are doing a smtp connection... I dont get what whould be useful for. If
    you are using header("locatio n"), it's because your file is on another
    place, so you should not send 200 ok as if the file requested is really
    here, see...

    Savut

    "John Wellesz" <john.wellesz-N0-SPAM-OR-BCURSED@firstre am.net> wrote in
    message news:Xns94B1C9E 45C1B2Lord2072@ 213.91.2.138...[color=blue]
    > Hello,
    >
    > It would be great if there was an option to tell PHP to let the user
    > manage all the HTTP headers instead of sending what it thinks is good for
    > the programmer...
    >
    > For example when you write:
    >
    > header("Status: 200 OK");
    > header("Locatio n: /my_internal_red irected_page.ph p");
    >
    > PHP "decides" that the status will be "302 moved", ignoring the "Status:
    > 200 OK" (ie: the programmer is stupid)...
    >
    > I use PHP as a cgi along with mod_fastcgi, when fastcgi sees a relative
    > redirection with a "200 OK" status it autaumatically do an internal
    > redirection (very useful in some cases, to hide a file url for example).
    >
    > Well, in PHP 4.3.4, the only way I found to achieve this was this
    > wonderful trick:
    >
    > header("Locatio n: /my_internal_red irected_page.ph p");
    > header("HTTP/1.0 200 OK");
    >
    > If you put the Location header after the "HTTP/1.0 200 OK" header PHP
    > sends a 302 status without the Location header (no comment).
    >
    > That reminds me Micro$oft programs that always know better what the user
    > wants to do than the user himself...
    >
    > It is a pity which PHP behaves like micro$oft, if the programmer sends
    > stupid HTTP headers, PHP should let him do...
    >
    > So I think that an option to let the programmer send all http headers
    > would be great, that way people who don't want to care about headers
    > won't have troubles and experimented programmers will be happy :)
    >
    >
    > I would like to thank all PHP developpers for their great work and I hope
    > they'll consider this suggestion ;)
    >
    >
    >
    >
    > John
    >
    >
    > PS: I posted this suggestion here because I don't know where to send
    > it... If someone knows a better place, please tell me.[/color]

    Comment

    • Tim Van Wassenhove

      #3
      Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

      On 2004-03-19, John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstre am.net> wrote:[color=blue]
      > Hello,
      >
      > It would be great if there was an option to tell PHP to let the user
      > manage all the HTTP headers instead of sending what it thinks is good for
      > the programmer...
      >
      > For example when you write:
      >
      > header("Status: 200 OK");
      > header("Locatio n: /my_internal_red irected_page.ph p");
      >
      > PHP "decides" that the status will be "302 moved", ignoring the "Status:
      > 200 OK" (ie: the programmer is stupid)...[/color]

      I don't see why it would be good to make up your own status codes?

      Question that i have right now: When buffering output, are the headers
      buffered too? Is there a way to do this?

      --

      Comment

      • Chung Leong

        #4
        Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

        Your suggestion would probably break 90% of the existing code out there that
        does redirection. Most PHP programmers don't supply the status code when
        they set the location header.

        Uzytkownik "John Wellesz" <john.wellesz-N0-SPAM-OR-BCURSED@firstre am.net>
        napisal w wiadomosci news:Xns94B1C9E 45C1B2Lord2072@ 213.91.2.138...[color=blue]
        > Hello,
        >
        > It would be great if there was an option to tell PHP to let the user
        > manage all the HTTP headers instead of sending what it thinks is good for
        > the programmer...
        >
        > For example when you write:
        >
        > header("Status: 200 OK");
        > header("Locatio n: /my_internal_red irected_page.ph p");
        >
        > PHP "decides" that the status will be "302 moved", ignoring the "Status:
        > 200 OK" (ie: the programmer is stupid)...
        >
        > I use PHP as a cgi along with mod_fastcgi, when fastcgi sees a relative
        > redirection with a "200 OK" status it autaumatically do an internal
        > redirection (very useful in some cases, to hide a file url for example).
        >
        > Well, in PHP 4.3.4, the only way I found to achieve this was this
        > wonderful trick:
        >
        > header("Locatio n: /my_internal_red irected_page.ph p");
        > header("HTTP/1.0 200 OK");
        >
        > If you put the Location header after the "HTTP/1.0 200 OK" header PHP
        > sends a 302 status without the Location header (no comment).
        >
        > That reminds me Micro$oft programs that always know better what the user
        > wants to do than the user himself...
        >
        > It is a pity which PHP behaves like micro$oft, if the programmer sends
        > stupid HTTP headers, PHP should let him do...
        >
        > So I think that an option to let the programmer send all http headers
        > would be great, that way people who don't want to care about headers
        > won't have troubles and experimented programmers will be happy :)
        >
        >
        > I would like to thank all PHP developpers for their great work and I hope
        > they'll consider this suggestion ;)[/color]


        Comment

        • Sean Malloy

          #5
          Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

          Thats the stupidest fucking thing I've ever heard.


          Comment

          • Tim Tyler

            #6
            Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

            Sean Malloy <nosuchuser@arc turus.com.au> wrote or quoted:
            [color=blue]
            > Thats the stupidest fucking thing I've ever heard.[/color]

            Not new to the net by any chance - are you? ;-)
            --
            __________
            |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

            Comment

            • Chung Leong

              #7
              Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

              Uzytkownik "Sean Malloy" <nosuchuser@arc turus.com.au> napisal w wiadomosci
              news:405c3c04$0 $241$702eb3a4@u t-29elizabeth-reader-01.hobart.pipen etworks.co
              m...[color=blue]
              > Thats the stupidest fucking thing I've ever heard.[/color]

              I guess you haven't seen the Matrix sequels yet.


              Comment

              • John Wellesz

                #8
                Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

                On 20 mars 2004, Sir Tim Van Wassenhove <euki@pi.be> claimed in
                news:c3fu96$28g 0ba$1@ID-188825.news.uni-berlin.de:
                [color=blue]
                >
                > Question that i have right now: When buffering output, are the headers
                > buffered too? Is there a way to do this?
                >[/color]

                No, when ythe output is buffered, the headers are not, they are sent
                directly.

                Comment

                • John Wellesz

                  #9
                  Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

                  On 19 mars 2004, Sir "Savut" <webki@hotmail. com> claimed in
                  news:UKI6c.3541 9$E71.1988825@n ews20.bellgloba l.com:
                  [color=blue]
                  > I dont approuve your suggestion because right now, it sends the correct
                  > header fallowing what you are doing with the http header.[/color]

                  I'm not agree, 302 is not an absolute correct answer. (see below)
                  [color=blue]
                  > Exemple, if you moved a file permanently and you send a 200 OK, we
                  > whould be in a world of mess.[/color]

                  It simply won't work... (we are not doing HTML)
                  and for permanently we send a 301 status code not a 302.

                  Actually the "Location" header is also used with those status codes:

                  - 201 Created
                  - 300 Multiple Choices
                  - 301 Moved Permanently
                  - 302 Found
                  - 303 See Other
                  - 307 Temporary Redirect

                  source: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
                  [color=blue]
                  > It's like you are connecting to a ftp server but want
                  > to fake him as you are doing a smtp connection... I dont get what
                  > whould be useful for. If you are using header("locatio n"), it's
                  > because your file is on another place, so you should not send 200 ok
                  > as if the file requested is really here, see...[/color]

                  200 means that the request has succeded not that the file "is here".

                  In CGI/1.1 standards, if you send a location with a _RELATIVE_ URL (an
                  absolute path), it HAS to do an internal redirection....

                  As mod_fastcgi for example (read the section
                  "Notes on CGI response headers"):


                  fastcgi/mod_fastcgi.htm l

                  PHP DOESN'T RESPECT THIS...

                  [color=blue]
                  > Your suggestion would probably break 90% of the existing code out
                  > there that does redirection. Most PHP programmers don't supply the
                  > status code when they set the location header.
                  >[/color]

                  That's why I suggest this as a new OPTION, disabled by default, to let
                  programmers manage headers without PHP interferences.. .


                  John

                  Comment

                  • R. Rajesh Jeba Anbiah

                    #10
                    Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

                    John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstre am.net> wrote in message news:<Xns94B1C9 E45C1B2Lord2072 @213.91.2.138>. ..[color=blue]
                    > Hello,
                    >
                    > It would be great if there was an option to tell PHP to let the user
                    > manage all the HTTP headers instead of sending what it thinks is good for
                    > the programmer...
                    >
                    > For example when you write:
                    >
                    > header("Status: 200 OK");
                    > header("Locatio n: /my_internal_red irected_page.ph p");
                    >
                    > PHP "decides" that the status will be "302 moved", ignoring the "Status:
                    > 200 OK" (ie: the programmer is stupid)...
                    >
                    > I use PHP as a cgi along with mod_fastcgi, when fastcgi sees a relative
                    > redirection with a "200 OK" status it autaumatically do an internal
                    > redirection (very useful in some cases, to hide a file url for example).
                    >
                    > Well, in PHP 4.3.4, the only way I found to achieve this was this
                    > wonderful trick:
                    >
                    > header("Locatio n: /my_internal_red irected_page.ph p");
                    > header("HTTP/1.0 200 OK");
                    >[/color]

                    Sounds like you're referring the user notes by ahring.de
                    (02-Dec-2003 09:24) found at <http://in.php.net/header>

                    In that case, the following is working fine:

                    <?php
                    header("Locatio n: http://www.google.com" );
                    header("Status: 200");
                    ?>

                    --
                    http://www.sendmetoindia.com - Send Me to India!
                    Email: rrjanbiah-at-Y!com

                    Comment

                    • John Wellesz

                      #11
                      Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

                      On 22 mars 2004, Sir ng4rrjanbiah@re diffmail.com (R. Rajesh Jeba Anbiah)
                      claimed in news:abc4d8b8.0 403212136.3cc9f 144@posting.goo gle.com:

                      [color=blue]
                      >
                      > Sounds like you're referring the user notes by ahring.de
                      > (02-Dec-2003 09:24) found at <http://in.php.net/header>
                      >
                      > In that case, the following is working fine:
                      >
                      > <?php
                      > header("Locatio n: http://www.google.com" );
                      > header("Status: 200");
                      > ?>
                      >[/color]

                      I tried that but it didn't work (302 was sent), at least with PHP 4.3.4 on
                      FreeBSD 4.9 STABLE, it seems that after a "Location" header, PHP only
                      considers 3xx status codes...

                      Comment

                      • Rob Tweed

                        #12
                        Re: A GREAT SUGGESTION TO PHP DEVELOPPERS

                        I agree and have made a similar comment before. There are
                        circumstances where it's desirable to take complete responsibility for
                        generating the full HTTP response including headers, but there's
                        currently no way of turning everything off. I hit against this problem
                        when doing R&D into a WebDAV implementation. In the end I had to
                        abandon the use of PHP as a gateway technology which was a great pity.
                        It seems that PHP adopts the "nanny knows best" attitude and assumes
                        responsibility in this area.

                        Rob


                        On 21 Mar 2004 21:36:13 -0800, ng4rrjanbiah@re diffmail.com (R. Rajesh
                        Jeba Anbiah) wrote:
                        [color=blue]
                        >John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstre am.net> wrote in message news:<Xns94B1C9 E45C1B2Lord2072 @213.91.2.138>. ..[color=green]
                        >> Hello,
                        >>
                        >> It would be great if there was an option to tell PHP to let the user
                        >> manage all the HTTP headers instead of sending what it thinks is good for
                        >> the programmer...
                        >>
                        >> For example when you write:
                        >>
                        >> header("Status: 200 OK");
                        >> header("Locatio n: /my_internal_red irected_page.ph p");
                        >>
                        >> PHP "decides" that the status will be "302 moved", ignoring the "Status:
                        >> 200 OK" (ie: the programmer is stupid)...
                        >>
                        >> I use PHP as a cgi along with mod_fastcgi, when fastcgi sees a relative
                        >> redirection with a "200 OK" status it autaumatically do an internal
                        >> redirection (very useful in some cases, to hide a file url for example).
                        >>
                        >> Well, in PHP 4.3.4, the only way I found to achieve this was this
                        >> wonderful trick:
                        >>
                        >> header("Locatio n: /my_internal_red irected_page.ph p");
                        >> header("HTTP/1.0 200 OK");
                        >>[/color]
                        >
                        > Sounds like you're referring the user notes by ahring.de
                        >(02-Dec-2003 09:24) found at <http://in.php.net/header>
                        >
                        > In that case, the following is working fine:
                        >
                        ><?php
                        >header("Locati on: http://www.google.com" );
                        >header("Status : 200");
                        >?>[/color]

                        ---
                        Rob Tweed
                        M/Gateway Developments Ltd

                        Global DOMination with eXtc : http://www.mgateway.tzo.com
                        ---

                        Comment

                        Working...