473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2300
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Frank Thorstens | last post by:
Hi, i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera. <?...
0
by: jock | last post by:
A script i'm working on is behaving real strange. It is more or less the same as dozens of others that work aok. Info is posted from one script to another, the second script does some work...
10
by: Andrea | last post by:
Hi everyone, I am in the process of learning javascript and have a question on location.href. Does javascript always require the <script language = "javascript"> (or script...
3
by: Christian Lutz | last post by:
Hy there I have a Web Services written in Java, running on Tomcat. The Client is written in C#. When i monitor the request/Response with TCPMon (included in Tomcat) i can observer the following...
6
by: G*rd*n | last post by:
I have been using the HTTP "Location" reponse header to direct a symbolic request to a CGI program to an actual URL/file. For example, let us suppose the CGI program's table indicates xyz ->...
23
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target...
0
by: wizofaus | last post by:
If you use your browser to navigate to http://www.fsa.gov.uk/register/, it will redirect you to http://www.fsa.gov.uk/register/home.do;jessionid= etc. etc. etc. But if you use WebRequest to fetch...
4
by: andre rodier | last post by:
Hello, I need to display or propose a jpeg image on a web page. When I need to display the image, I use this code : header("Content-Length: $fileSize") ; header("Content-Type: $type") ;...
3
by: C. Feldmann | last post by:
Hello, I have stumbled upon a problem, for which I can’t seem to find a solution for. I would like to offer files for downloading. To allow files to have duplicate names I renamed as random...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.