[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nisse Engström
On Fri, 20 Aug 2010 13:11:05 +0100, Nathan Rixham wrote:

> Nisse Engström wrote:
> 
>> Actually, the HTTP spec. allows most headers to be sent
>> after the content. The feature just wasn't implemented
>> by too many HTTP agents (W3's HTML validator and link
>> checker, and Opera).
> 
> can you send a link to where it says that in the spec, or in HTTPBis please





/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nathan Rixham

Nisse Engström wrote:

On Thu, 19 Aug 2010 17:47:01 -0600, Tristan wrote:


A rewrite of the entire site would be needed in order to fix. So, I guess
you are saying as best options for workaround are

- use the ob_ functions to work around.
- stick output buffer on or high

so best case scenario using ob_ functions as a cleaner method aside from
rewriting the code?

seems silly btw that you can't output html and just have it redirect
whenever you want it to at any point in the page.


Actually, the HTTP spec. allows most headers to be sent
after the content. The feature just wasn't implemented
by too many HTTP agents (W3's HTML validator and link
checker, and Opera).


can you send a link to where it says that in the spec, or in HTTPBis please

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nisse Engström
On Thu, 19 Aug 2010 17:47:01 -0600, Tristan wrote:

> A rewrite of the entire site would be needed in order to fix. So, I guess
> you are saying as best options for workaround are
> 
> - use the ob_ functions to work around.
> - stick output buffer on or high
> 
> so best case scenario using ob_ functions as a cleaner method aside from
> rewriting the code?
> 
> seems silly btw that you can't output html and just have it redirect
> whenever you want it to at any point in the page.

Actually, the HTTP spec. allows most headers to be sent
after the content. The feature just wasn't implemented
by too many HTTP agents (W3's HTML validator and link
checker, and Opera).


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-19 Thread Nathan Rixham

you can if you use a javascript redirect or an html meta refresh ~ish.

not really that silly tbh if you think about an HTTP message is like this:

Headers
...
MessageBody
.

the redirect is a header, so it get's sent through *before* the body, 
and the headers tell the client how to process the messagebody (or 
indeed whether to process it or just do something else).


consider an html page the same as a gif or a zip, it's just a chunk of 
computer data that gets sent in one, you wouldn't expect to be able to 
redirect somebody whilst they're halfway through downloading a big zip 
would you?


but yeah ob_** functions, this way you're catching the entire 
MessageBody (your html) before sending anything to the client, which 
then let's you send headers followed by body in your own time.


Best,

nathan

Tristan wrote:

A rewrite of the entire site would be needed in order to fix. So, I guess
you are saying as best options for workaround are

- use the ob_ functions to work around.
- stick output buffer on or high

so best case scenario using ob_ functions as a cleaner method aside from
rewriting the code?

seems silly btw that you can't output html and just have it redirect
whenever you want it to at any point in the page.

Thanks, T


On Thu, Aug 19, 2010 at 4:22 PM, Nathan Rixham  wrote:


Tristan wrote:


So, I'm have this site where all this code was developed and the logic
sits
in different plugins throughout a template. So, html is output and then
hits
one of these plugins. Plugins do some processing and then hit a
header(location...) redirect.

So, problem is they developed code with these header redirects and now we
there's too much html being output so we get the buffer errors

Cannot modify header information - headers already sent by (output started
at

/home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138)

to fix we have to up the buffer ouput in the php to something really high.

So, as far as I know this is not good coding practice and upping the
output
buffer is really masking the problem.

Is there another way to work around this like another way to do redirects
that won't cause these buffer probs?


Hi Tristan,

Really it's a nudge from your code that it needs refactored - however to
answer your question..

- there is no way to do an HTTP redirect once headers are sent
- you can use an html meta refresh, or javascript redirect - if the output
is going to be HTML viewed in a browser.

caveat, obviously robots and the like will still see the incorrect output -
it's a hack not a fix.

The other approach is to use ob_start() and related functions to capture
all the code generated without any output being sent to the browser, this
should allow you to send the header down when needed.

Certainly wouldn't just knock output buffering right up high to work around
it if I was you.

Best,

Nathan






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-19 Thread Tristan
A rewrite of the entire site would be needed in order to fix. So, I guess
you are saying as best options for workaround are

- use the ob_ functions to work around.
- stick output buffer on or high

so best case scenario using ob_ functions as a cleaner method aside from
rewriting the code?

seems silly btw that you can't output html and just have it redirect
whenever you want it to at any point in the page.

Thanks, T


On Thu, Aug 19, 2010 at 4:22 PM, Nathan Rixham  wrote:

> Tristan wrote:
>
>> So, I'm have this site where all this code was developed and the logic
>> sits
>> in different plugins throughout a template. So, html is output and then
>> hits
>> one of these plugins. Plugins do some processing and then hit a
>> header(location...) redirect.
>>
>> So, problem is they developed code with these header redirects and now we
>> there's too much html being output so we get the buffer errors
>>
>> Cannot modify header information - headers already sent by (output started
>> at
>>
>> /home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138)
>>
>> to fix we have to up the buffer ouput in the php to something really high.
>>
>> So, as far as I know this is not good coding practice and upping the
>> output
>> buffer is really masking the problem.
>>
>> Is there another way to work around this like another way to do redirects
>> that won't cause these buffer probs?
>>
>
> Hi Tristan,
>
> Really it's a nudge from your code that it needs refactored - however to
> answer your question..
>
> - there is no way to do an HTTP redirect once headers are sent
> - you can use an html meta refresh, or javascript redirect - if the output
> is going to be HTML viewed in a browser.
>
> caveat, obviously robots and the like will still see the incorrect output -
> it's a hack not a fix.
>
> The other approach is to use ob_start() and related functions to capture
> all the code generated without any output being sent to the browser, this
> should allow you to send the header down when needed.
>
> Certainly wouldn't just knock output buffering right up high to work around
> it if I was you.
>
> Best,
>
> Nathan
>


[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-19 Thread Nathan Rixham

Tristan wrote:

So, I'm have this site where all this code was developed and the logic sits
in different plugins throughout a template. So, html is output and then hits
one of these plugins. Plugins do some processing and then hit a
header(location...) redirect.

So, problem is they developed code with these header redirects and now we
there's too much html being output so we get the buffer errors

Cannot modify header information - headers already sent by (output started
at
/home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138)

to fix we have to up the buffer ouput in the php to something really high.

So, as far as I know this is not good coding practice and upping the output
buffer is really masking the problem.

Is there another way to work around this like another way to do redirects
that won't cause these buffer probs?


Hi Tristan,

Really it's a nudge from your code that it needs refactored - however to 
answer your question..


- there is no way to do an HTTP redirect once headers are sent
- you can use an html meta refresh, or javascript redirect - if the 
output is going to be HTML viewed in a browser.


caveat, obviously robots and the like will still see the incorrect 
output - it's a hack not a fix.


The other approach is to use ob_start() and related functions to capture 
all the code generated without any output being sent to the browser, 
this should allow you to send the header down when needed.


Certainly wouldn't just knock output buffering right up high to work 
around it if I was you.


Best,

Nathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php