By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,333 Members | 1,843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,333 IT Pros & Developers. It's quick & easy.

A GREAT SUGGESTION TO PHP DEVELOPPERS

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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" <jo*****************************@firstream.net> wrote in
message news:Xn**********************@213.91.2.138...
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.


Jul 17 '05 #2

P: n/a
On 2004-03-19, John Wellesz <jo*****************************@firstream.net> wrote:
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 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
Jul 17 '05 #3

P: n/a
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" <jo*****************************@firstream.net>
napisal w wiadomosci news:Xn**********************@213.91.2.138...
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 ;)

Jul 17 '05 #4

P: n/a
Thats the stupidest fucking thing I've ever heard.
Jul 17 '05 #5

P: n/a
Sean Malloy <no********@arcturus.com.au> wrote or quoted:
Thats the stupidest fucking thing I've ever heard.


Not new to the net by any chance - are you? ;-)
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #6

P: n/a
Uzytkownik "Sean Malloy" <no********@arcturus.com.au> napisal w wiadomosci
news:40*********************@ut-29elizabeth-reader-01.hobart.pipenetworks.co
m...
Thats the stupidest fucking thing I've ever heard.


I guess you haven't seen the Matrix sequels yet.
Jul 17 '05 #7

P: n/a
On 20 mars 2004, Sir Tim Van Wassenhove <eu**@pi.be> claimed in
news:c3*************@ID-188825.news.uni-berlin.de:

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


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

Jul 17 '05 #8

P: n/a
On 19 mars 2004, Sir "Savut" <we***@hotmail.com> claimed in
news:UK*********************@news20.bellglobal.com :
I dont approuve your suggestion because right now, it sends the correct
header fallowing what you are doing with the http header.
I'm not agree, 302 is not an absolute correct answer. (see below)
Exemple, if you moved a file permanently and you send a 200 OK, we
whould be in a world of mess.
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
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...
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...

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.


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

P: n/a
John Wellesz <jo*****************************@firstream.net> wrote in message news:<Xn**********************@213.91.2.138>...
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");


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
Jul 17 '05 #10

P: n/a
On 22 mars 2004, Sir ng**********@rediffmail.com (R. Rajesh Jeba Anbiah)
claimed in news:ab**************************@posting.google.c om:


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");
?>


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...
Jul 17 '05 #11

P: n/a
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, ng**********@rediffmail.com (R. Rajesh
Jeba Anbiah) wrote:
John Wellesz <jo*****************************@firstream.net> wrote in message news:<Xn**********************@213.91.2.138>...
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");


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");
?>


---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---
Jul 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.