471,319 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

location header WORKING after content written...why?

As far as I know, http headers should not work after content has been
written. This is how my production box is working, but for some reason
on my dev box I was getting away with a location header after content
(some debug notes) was written.

Just to be sure, I threw a die() in right before the header('Location:
'...) call, and sure enough there was the same stuff on screen that
the live box is choking on.

So does anyone have any ideas on what I might have set that allowed me
to get away with this? It's not a capability I enjoy. Environment is
Apache 2 on Redhat AS3.

Many thanks

Jul 17 '05 #1
11 2196
On 20 Apr 2005 10:48:16 -0700, pi****@gmail.com wrote:
As far as I know, http headers should not work after content has been
written. This is how my production box is working, but for some reason
on my dev box I was getting away with a location header after content
(some debug notes) was written.

Just to be sure, I threw a die() in right before the header('Location:
'...) call, and sure enough there was the same stuff on screen that
the live box is choking on.

So does anyone have any ideas on what I might have set that allowed me
to get away with this? It's not a capability I enjoy. Environment is
Apache 2 on Redhat AS3.


You can get away with it if output buffering is on and you write the header
before the first flush.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
pi****@gmail.com wrote:
: As far as I know, http headers should not work after content has been
: written. This is how my production box is working, but for some reason
: on my dev box I was getting away with a location header after content
: (some debug notes) was written.

perhaps the debug messages are not going to stdout, and perhaps stdout is
not being sent to the browser.

--

This space not for rent.
Jul 17 '05 #3
No output buffering going on--at least theres no ob_start calls in any
of the files involved. Could there be some kind of buffering as a
server configuration? That sounds pretty strange.

Also, the debug in question boils down to a print_r call, so I haven't
knowingly done anything to route that output anywhere unusual.

Thanks for the replies, of course.

Still baffled.

Jul 17 '05 #4
On 20 Apr 2005 12:51:06 -0700, pi****@gmail.com wrote:
No output buffering going on--at least theres no ob_start calls in any
of the files involved. Could there be some kind of buffering as a
server configuration? That sounds pretty strange.


There are transparent compression options in php.ini that use the output
buffering mechanism; these could be turned on.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #5
On Wed, 20 Apr 2005 19:55:54 +0100, Andy Hassall wrote:
On 20 Apr 2005 10:48:16 -0700, pi****@gmail.com wrote:
As far as I know, http headers should not work after content has been
written. This is how my production box is working, but for some reason
on my dev box I was getting away with a location header after content
(some debug notes) was written.

Just to be sure, I threw a die() in right before the header('Location:
'...) call, and sure enough there was the same stuff on screen that
the live box is choking on.

So does anyone have any ideas on what I might have set that allowed me
to get away with this? It's not a capability I enjoy. Environment is
Apache 2 on Redhat AS3.


You can get away with it if output buffering is on and you write the header
before the first flush.


as per:-

http://www.php.net/manual/en/ref.out...tput-buffering

Jul 17 '05 #6
pi****@gmail.com wrote:
No output buffering going on--at least theres no ob_start calls in any of the files involved. Could there be some kind of buffering as a
server configuration? That sounds pretty strange.

<snip>

Was it really header('Location..') or header('Refresh...')? The later
will work after writing the contents.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #7
On 24 Apr 2005 02:40:37 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote:
pi****@gmail.com wrote:
No output buffering going on--at least theres no ob_start calls in

any
of the files involved. Could there be some kind of buffering as a
server configuration? That sounds pretty strange.

<snip>

Was it really header('Location..') or header('Refresh...')? The later
will work after writing the contents.


No, it won't. Refresh is not an HTTP header, and headers still cannot be sent
after content.

Perhaps you're thinking of a <meta> tag within the content.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #8
Andy Hassall wrote:
On 24 Apr 2005 02:40:37 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote: <snip>
Was it really header('Location..') or header('Refresh...')? The laterwill work after writing the contents.


No, it won't. Refresh is not an HTTP header, and headers still

cannot be sent after content.

Perhaps you're thinking of a <meta> tag within the content.


No. I'm talking about header('Refresh: 5;
URL=http://www.example.com/')--not sure if it is a standard header and
in HTTP spec. Though the header has to be sent before contents, in the
page the redirection will happen only after outputting the
contents--same like META refresh. Thought that OP is talking about
similar situation.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #9
On 24 Apr 2005 05:15:46 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote:
Andy Hassall wrote:
On 24 Apr 2005 02:40:37 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote:

<snip>
> Was it really header('Location..') or header('Refresh...')? Thelater >will work after writing the contents.


No, it won't. Refresh is not an HTTP header, and headers still

cannot be sent
after content.

Perhaps you're thinking of a <meta> tag within the content.


No. I'm talking about header('Refresh: 5;
URL=http://www.example.com/')--not sure if it is a standard header and
in HTTP spec.


It is not.

http://www.w3.org/Protocols/rfc2616/rfc2616.html

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #10
Andy Hassall wrote:
<snip>
No. I'm talking about header('Refresh: 5;
URL=http://www.example.com/')--not sure if it is a standard header andin HTTP spec.


It is not.

http://www.w3.org/Protocols/rfc2616/rfc2616.html


Oh, thanks. FWIW, IIRC, I read somewhere that header('Location..')
will crash IIS, but not header refresh.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #11
On 24 Apr 2005 05:29:51 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote:
Andy Hassall wrote:
<snip>
> No. I'm talking about header('Refresh: 5;
>URL=http://www.example.com/')--not sure if it is a standard headerand >in HTTP spec.


It is not.

http://www.w3.org/Protocols/rfc2616/rfc2616.html


Oh, thanks. FWIW, IIRC, I read somewhere that header('Location..')
will crash IIS, but not header refresh.


The only references I can find to this is are certain circumstances where
sending a relative URI through Location on old versions of ISS reportedly
results in a crash. This is forbidden by the standards anyway, you must send an
absolute URI in the first place.

Presumably it doesn't crash using Refresh because this is a made-up header and
so there's no additional code it runs to correct relative URIs.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Frank Thorstens | last post: by
3 posts views Thread by Christian Lutz | last post: by
6 posts views Thread by G*rd*n | last post: by
3 posts views Thread by C. Feldmann | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.