473,241 Members | 1,426 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,241 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 2298
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.