Welcome!
Welcome! ( Recent posts | Mark all | Login | Register )
» Quicksilver Forums » Project » Patches/Additions » [patch] speed up download of ...

[patch] speed up download of attachments
< Newer Topic :: Older Topic > Downloading attachments was slow

Post is unread #1 Jan 30, 2009, 9:32 pm
Go to the bottom of the page Go to the top of the page
This member is currently offline Tino Schwarze
Newbie Member Level
GroupMembers
Posts3
JoinedJun 3, 2008
WWW PM

The download started, then seemed to pause and hang.

I looked into it and found that all data is transfered, but the connection is not closed because of a
Quote:
Connection: Keep-Alive

HTTP header sent back to the client. The download finished after my Apache server closed the connection.

I patched func/topic.php as follows:
Code:
diff -u -r1.1 topic.php
--- func/topic.php	12 Oct 2008 19:58:17 -0000	1.1
+++ func/topic.php	30 Jan 2009 20:28:57 -0000
@@ -586,11 +586,13 @@
 			session_write_close();
 
 			ini_set("zlib.output_compression", "Off");
+			header("Connection: close");
 			header("Content-Type: application/octet-stream");
 			header("Content-Disposition: attachment; filename=\"{$data['attach_name']}\"");
 			header("Content-Length: " . $data['attach_size']);
 			header("X-Robots-Tag: noarchive, nosnippet, noindex");
-			echo file_get_contents('./attachments/' . $data['attach_file']);
+			# directly pass through file to output buffer
+			@readfile ('./attachments/' . $data['attach_file']);
 		} else {
 			return $this->message($this->lang->topic_attached_title, $this->lang->topic_attached_perm);
 		}

While being at it, I also replaced the "echo file_get_contents(...)" by readfile() which should be more efficient.

Hope it heps,

Tino Emanuel.

PS: I patched my way around multibyte/UTF-8 problems as well - if anybody is interested, I'll contribute the patches (which involve missing German translations as well and fixing everything up for UTF-8).
       
Post is unread #2 Feb 3, 2009, 11:23 am
Go to the bottom of the page Go to the top of the page
Avatar

This member is currently offline Detruire
Droplet Member Level
GroupMembers
Posts164
JoinedDec 28, 2005
WWW Yahoo MSN GT PM

readfile should work better with large files, as it's supposed to output as it reads. .........................
Syridium | Detruire

My HForumv3 skin has now been updated for QSF 1.4.1! Download the latest version from the concepts:)
       
Post is unread #3 Feb 15, 2010, 10:07 am
Go to the bottom of the page Go to the top of the page
Avatar

This member is currently offline Samson
Scaly but Handsome Member Level
GroupAdministrators
Posts2,086
JoinedSep 6, 2005
WWW PM

Well, better late than never on the file downloads patch. Thanks for that, if you happen to swing by again.

I'd commit it to the svn, but I lost the password and berlios.de has the wrong email account to re-validate it. .........................
PDNS-Admin | Sandbox | Arthmoor MUD Hosting Services | The Truth About Medievia: A Saga of Code Theft.

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
       
Pages:<< prev 1 next >>