Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct. 11, 2008, 01:53:13 PM
47671 Posts in 10454 Topics by 5339 Members
Latest Member: phamlehoaian
News: Share your PRADO experience with other PRADOers by commenting on the QuickStart Tutorial.
 
The PRADO Community » Prado v3.x » General Discussion » Output Buffering Problem « previous next »
Pages: [1] Print
Author Topic: Output Buffering Problem  (Read 674 times)
jake
Platinum Member
****

Karma: 13
Offline Offline

Posts: 888



View Profile
« on: Apr. 25, 2008, 08:36:17 PM »

I created a service class that outputs movie files to the browser and I tried clearing the output buffer before I output the file but when I do that and click another page while the movie is playing I get an error.

Here is the main code that outputs the video from my service:

Code:
ob_clean();
flush();
ob_end_flush();

// Vars
$filePath=realpath($file->getFileLocation());
$chunkSize= 1 * (1024 * 1024); // How many bytes per chunk
$buffer='';

$fileHandle=fopen($filePath, 'rb');
while (!feof($fileHandle))
{
$buffer=fread($fileHandle, $chunkSize);
echo $buffer;
//ob_flush(); flush();
}
fclose($fileHandle);

And here is the error I am getting:

Quote
Warning: Cannot modify header information - headers already sent in /usr/share/php5/prado-trunk/framework/Exceptions/TErrorHandler.php on line 168

<!DOCTYPE html PUBLIC

        "-//W3C//DTD XHTML 1.0 Transitional//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>Internal Server Error</title>

<style type="text/css">

/*<![CDATA[*/

body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}

h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}

p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px}

.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}

/*]]>*/

</style>

</head>

<body>

<h1>Internal Server Error</h1>

<h2>[Warning] Cannot modify header information - headers already sent (@line 420 in file /usr/share/php5/prado-trunk/framework/Web/THttpResponse.php).</h2>

<p>

An internal error occurred while the Web server was handling your request.

Please contact the <a href="mailto:me@localhostcom">webmaster</a> to report this problem.

</p>

<p>

Thank you.

</p>

<div class="version">

2008-04-25 09:34

</div>

</body>

</html>HTTP/1.1 302 Found

Date: Fri, 25 Apr 2008 16:34:24 GMT

Server: Apache/2.2.4 (Linux/SUSE)

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Location: http://mysite/index.htm/page,Revisions.PreviewFile/file,202

Content-Length: 0

Keep-Alive: timeout=15, max=96

Connection: Keep-Alive

Content-Type: text/html

I noticed that THttpResponse is doing some output buffering stuff by the error I am getting above by why does that break and show the error above when I try clicking on a link while a page is playing a movie that I am sending from my application?

Thanks.
« Last Edit: Apr. 26, 2008, 06:25:50 PM by jake » Logged
intol
Senior Member
***

Karma: 5
Offline Offline

Posts: 151


View Profile WWW
« Reply #1 on: Apr. 26, 2008, 06:23:24 PM »

It's bug: http://trac.pradosoft.com/prado/ticket/841 .

(it's not connected - my mistake)
« Last Edit: May. 06, 2008, 09:17:47 PM by intol » Logged

jake
Platinum Member
****

Karma: 13
Offline Offline

Posts: 888



View Profile
« Reply #2 on: Apr. 28, 2008, 07:23:14 AM »

Anyone else got any suggestions on how to output a video through Prado? If I try disabling output buffering in the response module then my whole site gets messed up and if I just try disabling output buffering for that service it doesn't make a difference.

I'm open to ideas and hope I can use Prado for everything and not have to create a side script to display my videos instead of just using Prado.
Logged
jake
Platinum Member
****

Karma: 13
Offline Offline

Posts: 888



View Profile
« Reply #3 on: Apr. 28, 2008, 10:10:20 PM »

Ok I fixed my problem. I had to move my code that outputted the appropriate headers from the run() method to the init() method and now everything works fine.

However something didn't work as expected. I tried setting the content type from the response object ( $this->getResponse()->setContentType('video/quicktime') ) in my init() method but every time I looked in the headers it always came out text/html. Instead I just manually added it by using appendHeader() and it worked but why won't using the method created for it work?

Thanks.
Logged
Pages: [1] Print 
« previous next »
Jump to: