PDA

View Full Version : Use thttpd for attachments..?


Robbban
Thu 13th Jan '05, 11:53am
Can I use thttpd for attachments..? Or isn't that a good idea?

Erwin
Thu 13th Jan '05, 6:43pm
You can't unless you use thttpd with the php extension. Attachments require PHP as you want permissions to be checked. thttpd by default only serves static files.

Robbban
Fri 14th Jan '05, 9:38am
OK... Maybe can make attachment.php call thttpd for the required file after checking the permission... Do you get my point? :) Need to reduce Apache and have MySQL and thttpd on an separate server...

Erwin
Sat 15th Jan '05, 11:54pm
If thttpd can call it, then any guest can call it too - permissions won't work.

kmike
Mon 17th Jan '05, 2:35am
Even sans permissions, redirecting requests for attachments from apache to thttpd won't work without some serious C hacking - attachment's filename and content type are stored in db only, so they need to be passed to thttpd somehow, either via URL or via custom HTTP headers. Then thttpd has to pick them up and substitute as real filename and content type.

Erwin
Mon 17th Jan '05, 7:35pm
Even sans permissions, redirecting requests for attachments from apache to thttpd won't work without some serious C hacking - attachment's filename and content type are stored in db only, so they need to be passed to thttpd somehow, either via URL or via custom HTTP headers. Then thttpd has to pick them up and substitute as real filename and content type.
It can be done if you don't bother with permissions - just use a subdomain for thttpd, and use php to redirect calls to the direct URL for the attachment.

kmike
Tue 18th Jan '05, 2:12am
It can be done if you don't bother with permissions - just use a subdomain for thttpd, and use php to redirect calls to the direct URL for the attachment.
Erwin, if you're citing me from the "large boards" thread, I was wrong there. I had a close look at this recently. Attachments are stored in filesystem with generated filename, which is based on userid and attachmentid, and doesn't contain real filename. You can't simply redirect to that filepath, you have to pass real filename and content-type along way. The problem is, thttpd will drop those headers after redirect, and browser will get some "/3/2/1/3562.attach" filename with application/octet-stream type or whatever default content-type is defined in thttpd.

Raz Meister
Tue 18th Jan '05, 3:38pm
You will see more benefit from moving your images over to thttpd than attachments.

Unless you have an abundance of attachments, like serveral for every thread, then it makes no sense to try to move it to thttpd.

Erwin
Tue 18th Jan '05, 11:20pm
Erwin, if you're citing me from the "large boards" thread, I was wrong there. I had a close look at this recently. Attachments are stored in filesystem with generated filename, which is based on userid and attachmentid, and doesn't contain real filename. You can't simply redirect to that filepath, you have to pass real filename and content-type along way. The problem is, thttpd will drop those headers after redirect, and browser will get some "/3/2/1/3562.attach" filename with application/octet-stream type or whatever default content-type is defined in thttpd.
I wasn't citing you per se, but I didn't realize that was the case... mmm... I was fairly sure it was possible... anyway, I have a dedicated server for attachments anyway.