Forum Discussion
Octavian_Hornoi
Nimbostratus
Jul 15, 2008Renaming File In Transit
One of our partners is hosting a web page where users can select which songs (mp3s) they want to purchase and then after they purchase the mp3 they can click on a link and download them.
The problem we are running into is that each download link is a tokenized URL in our system such as:
http://download-ourdomain.com/GetFile?token=fjkl;d6y4re392fjfdkafdsa;
When the user receives the download, the filename in the browser is set to the token number and it looks like garbage (fjkl;d6y4re392fjfdkafdsa;.mp3). Obviously, we would like to fix this.
We were considering perhaps passing in an additional parameter to the BigIP that it could then interpret and rename the file in transit:
http://download-ourdomain.com/GetFile?filename=99_red_balloons.mp3&token=fjkl;d6y4re392fjfdkafdsa;
In this case, the BigIP would strip "filename=99_red_balloons.mp3" from the URL, request the file from the server behind it and then return the file to the requesting browser as "99_red_balloons.mp3".
Is this even possible? If it is, how would we go about doing it?
Thanks!
- hoolio
Cirrostratus
Hi, - Octavian_Hornoi
Nimbostratus
We have custom code on our download servers written in perl that expects a method call of GetFile with a token. This cannot be altered due to other partners using this method already. We have to either change the name in transit or else, if we cannot do this via BigIP, we will have to have this new partner proxy our content. This is less desirable since it negates the whole point of having us as a download resource. - hoolio
Cirrostratus
Sure, you can do that with an iRule. The only thing changing from 'http://download-ourdomain.com/99_red_balloons.mp3?token=fjkld6y4re392fjfdkafdsa ' to 'http://download-ourdomain.com/GetFile?token=fjkl;d6y4re392fjfdkafdsa;' is the path. You can use HTTP::path to change this:when HTTP_REQUEST { Check if requested object is an mp3 (or use some other criteria to determine when to rewrite the path if {[HTTP::path] ends_with ".mp3"}{ HTTP::path "/GetFile" } }
- Octavian_Hornoi
Nimbostratus
And from the user's perspective in their browser, they would still see the URL as ending in .mp3 correct? After the content is returned that is. - hoolio
Cirrostratus
That's correct. The path is rewritten before the request is sent to the pool The browser address bar would get updated if instead you sent a redirect to the client to the /GetFile object. - Octavian_Hornoi
Nimbostratus
Ok, this is great. We will test it today or tomorrow and see what results we get. Thanks for the quick, creative response.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects