PDA

View Full Version : File Name at HTTP Response Header


blockout69
5th July 2009, 06:23 PM
Some image hosts like Imagebam send the file names of images in a response header named "Content-disposition". All current browsers and some bulk download tools could handle this. You may have noticed saving an image from such hosts in the browser results in a different file name as with IHG.
Today i had some time on my hands and made some few modifications to utils.js and progress_listener.js to allow setting the file name after reading the response header. It may be activated in hostf.xml for single hosts.
If someone is interested i put the modified code here.
BTW: This is a great tool. Thanks a lot!

cybormatt
6th July 2009, 10:16 AM
Ummm, I'd be interested to see what modifications you've made. Please, lets see it.

blockout69
7th July 2009, 10:09 PM
The changed files (base version 1.57) are here:
************/file/7ykp2l

Please replace ******** with
u p l o a d e d <point> t o

To activate it you need to set
retVal.fileName = "need_a_name";
in hostf.xml

I have put the file name handling in a method getOutputFile() which is called from doStartDownload() for fixed file names and ProgressListener.onStartRequest for file names set by response headers.

blockout69
7th July 2009, 10:15 PM
Whats wrong here with OCH links. Tried NL and UL with no success.

cybormatt
8th July 2009, 09:33 AM
Whats wrong here with OCH links. Tried NL and UL with no success.

I don't understand what you're talking about by "OCH" links, and what you mean by "Tried NL and UL".


By the way, who are you? I've reviewed the changes you've made... and you made me think. To be honest, I wasn't expecting this. Alot of people that submit some code are capable of some javascript, but you have some understanding of utilizing xpcom, which tells me that you have experience with extensions, or you spent more time on this than you're willing to admit ;)

You're logical programming is sound. I don't think I will want to modify the hostf.xml file to include the statement "retVal.filename = "need_a_name" . Instead, I will try to implement a conditional statement that will see if the "Content-disposition" field exists, and if it does, then just set the filename based on that.

I will need some time to review your changes so I can adapt them to my plans. Many people have requested better file naming conventions... and frankly, I haven't cared enough to do anything about it. Since you've done the foot work, and since you've brought to my attention about this response header field (which I did not know about), I can now implement some better file names.

Right now, my attention is on getting my new forum up and running. Once I figure out how to merge all of the topics here into my new forum, then I can focus on this update. You don't happen to have any experience with making algorithms more efficient, do you?

thanks a bunch bro!

web_surfer
8th July 2009, 02:53 PM
Interesting stuff, dude. Thanks for the code.

blockout69
8th July 2009, 08:00 PM
I don't understand what you're talking about by "OCH" links, and what you mean by "Tried NL and UL".
OK OK. I was in hurry. OCH stands for one click hosting. NL and UL for two hosters i can not mention here because the forum always replaces the text by *******. Anyway you got the code.
About me:
I am doing programming in C and later C++ since many years. It is a pity i am now constrained to use such things like Java and Dotnet. I had some experience with XPCOM because i had realized a toolbar for FF some years ago. I have learned a lot from the code of Adblock (the original one).
I had changed your previous version 1.4 also. The approach was different because you took a inbuilt function to download the image and save the file.

cybormatt
23rd July 2009, 09:58 AM
I am proud to announce that your changes have been accepted with just a few modifications. I am still working out a minor bug, but I will save it for tomorrow. Look for the implementations in the next release (v1.5.9) in the next couple of days.

cybormatt
24th July 2009, 06:20 AM
okay, the new version is out! check it out and tell me what you think