A GREAT SUGGESTION TO PHP DEVELOPPERS 
July 17th, 2005, 04:18 AM
| | | 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("Location: /my_internal_redirected_page.php");
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("Location: /my_internal_redirected_page.php");
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. | 
July 17th, 2005, 04:18 AM
| | | 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("location"), 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@firstream.net> wrote in
message news:Xns94B1C9E45C1B2Lord2072@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("Location: /my_internal_redirected_page.php");
>
> 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("Location: /my_internal_redirected_page.php");
> 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] | 
July 17th, 2005, 04:18 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
On 2004-03-19, John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstream.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("Location: /my_internal_redirected_page.php");
>
> 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?
-- http://home.mysth.be/~timvw | 
July 17th, 2005, 04:19 AM
| | | 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@firstream.net>
napisal w wiadomosci news:Xns94B1C9E45C1B2Lord2072@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("Location: /my_internal_redirected_page.php");
>
> 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("Location: /my_internal_redirected_page.php");
> 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] | 
July 17th, 2005, 04:19 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
Thats the stupidest fucking thing I've ever heard. | 
July 17th, 2005, 04:19 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
Sean Malloy <nosuchuser@arcturus.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. | 
July 17th, 2005, 04:19 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
Uzytkownik "Sean Malloy" <nosuchuser@arcturus.com.au> napisal w wiadomosci
news:405c3c04$0$241$702eb3a4@ut-29elizabeth-reader-01.hobart.pipenetworks.co
m...[color=blue]
> Thats the stupidest fucking thing I've ever heard.[/color]
I guess you haven't seen the Matrix sequels yet. | 
July 17th, 2005, 04:20 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
On 20 mars 2004, Sir Tim Van Wassenhove <euki@pi.be> claimed in
news:c3fu96$28g0ba$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. | 
July 17th, 2005, 04:20 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
On 19 mars 2004, Sir "Savut" <webki@hotmail.com> claimed in
news:UKI6c.35419$E71.1988825@news20.bellglobal.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("location"), 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"): http://www.fastcgi.com/om_archive/se...apache/apache-
fastcgi/mod_fastcgi.html
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 | 
July 17th, 2005, 04:20 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstream.net> wrote in message news:<Xns94B1C9E45C1B2Lord2072@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("Location: /my_internal_redirected_page.php");
>
> 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("Location: /my_internal_redirected_page.php");
> 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("Location: http://www.google.com");
header("Status: 200");
?>
-- http://www.sendmetoindia.com - Send Me to India!
Email: rrjanbiah-at-Y!com | 
July 17th, 2005, 04:20 AM
| | | Re: A GREAT SUGGESTION TO PHP DEVELOPPERS
On 22 mars 2004, Sir ng4rrjanbiah@rediffmail.com (R. Rajesh Jeba Anbiah)
claimed in news:abc4d8b8.0403212136.3cc9f144@posting.google.c om:
[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("Location: 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... | 
July 17th, 2005, 04:22 AM
| | | 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@rediffmail.com (R. Rajesh
Jeba Anbiah) wrote:
[color=blue]
>John Wellesz <john.wellesz-N0-SPAM-OR-BCURSED@firstream.net> wrote in message news:<Xns94B1C9E45C1B2Lord2072@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("Location: /my_internal_redirected_page.php");
>>
>> 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("Location: /my_internal_redirected_page.php");
>> 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("Location: http://www.google.com");
>header("Status: 200");
>?>[/color]
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|