LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > Turn off buffering!?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2009, 10:20 AM
f4nny f4nny is offline
New Member
 
Join Date: May 2009
Posts: 1
Default Turn off buffering!?

Hello ,
I wrote a code in php to read a file from remote server and send the content to a user , something like a proxy.
-----
PHP Code:
$fp fsockopen('address.com'80$errno$errstr);
...
//some code to send headers to http://address.com/ server to get 1.rar file.
fputs($fp$headers);
fflush($fp);
while (!
feof($fp))
{
    echo 
fgets($fp'1024');
    
ob_end_flush();

----
for example if 1.rar is about 50meg , and a user have 100KB connection ,when he start to download that file , the server read that file with 10 MB speed and send it to user.That cause server to read all file and buffer it and send it to user , and get more memory.
I can't limit the script speed , because my users have different speed , but I want my script read data and wait until the data send to user and then read the next segment of data.
Is there any config in litespeed to correct this for me?
Thanks.
Reply With Quote
  #2  
Old 05-15-2009, 10:28 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
It is not possible, LiteSpeed is designed to buffer the response body and make PHP process available for next request as fast as it can.
Please read more about "External Application Firewall" on page
http://www.litespeedtech.com/litespe...-features.html
Reply With Quote
  #3  
Old 05-16-2009, 01:32 PM
karname karname is offline
New Member
 
Join Date: May 2009
Posts: 1
Angry same problem

hi ,
I have the same problem as f4nny does.
I monitor download script and figure out that for example , a user download about 10 meg in 1 min , and the server cahce about 335 meg! for a file with 65 meg size . That's horrible!
You mean there is no option to control this!?
I think server runs my script and caches data before deliver to my user and if my user stopping to download , the cache will be wasted.
i adapted my code from f4nny's code :
PHP Code:
<?php
$name
=rand().'.txt';
$hand=fopen($name,'w');
$fp fsockopen('address.com'80$errno$errstr);
...
//some code to send headers to http://address.com/ server to get 1.rar file.
fputs($fp$headers);
fflush($fp);
while (!
feof($fp))
{
    echo 
$bfgets($fp'1024');
    
fwrite($hand,$b);
    
ob_end_flush();
}  
?>

Last edited by karname; 05-16-2009 at 02:08 PM..
Reply With Quote
  #4  
Old 05-16-2009, 06:01 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
It is not possible now.
You need to slow down your PHP script if you want to.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:52 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.