Re: WORedirect with a known MIME type?
Re: WORedirect with a known MIME type?
- Subject: Re: WORedirect with a known MIME type?
- From: OC <email@hidden>
- Date: Tue, 11 Oct 2016 18:53:33 +0200
Samuel and all others,
thanks a lot!
On 10. 10. 2016, at 22:39, Samuel Pelletier <email@hidden> wrote:
> The mime type of the final file is sent by the final web server. The redirect simply tell the browser to get the content elsewhere and does not define it's type.
That's in other words what I asked for -- whether the redirection HTTP allows a way to specify the desired headers for the final response (especially the target MIME), and if so, whether WORedirect has an access to that way.
Alas, looks like there is no such a way.
> In Apache, the mime type sent is defined in a mime.types file in the conf directory. The matching is based on the file extension.
> You can orreride the default with configuration directives.
Without a file extension (or with an essentially random extensions), not easily (perhaps it might work through <filesMatch> in .htaccess, am not sure). Nevertheless, meantime I succeeded to explain to my client that it would be much better to force some hard-coded file extensions based on the MIME types, which solves the problem very nicely :)
Thanks,
OC
>> Le 9 oct. 2016 à 15:24, email@hidden a écrit :
>>
>> Hello there,
>>
>> at the moment, my application can return a file to the user through
>>
>> ===
>> WOResponse downloadFile(String mimeType, File path) {
>> WOResponse wor=new WOResponse()
>> wor.setHeader("$mimeType; name=\"$path.name\"","content-type")
>> wor.setContent(path.getText("utf-8"))
>> wor.disableClientCaching()
>> wor.removeHeadersForKey("Cache-Control")
>> wor.removeHeadersForKey("cache-control")
>> wor.removeHeadersForKey("pragma")
>> wor
>> }
>> ===
>>
>> The 'path' though happens to map to an URL, accessible directly through the HTTP server (without a need to go through the application at all). Therefore, I would like to replace the code above by something like
>>
>> ===
>> WORedirect downloadFile(String mimeType, File path) {
>> WORedirect wor=new WORedirect(context())
>> wor.setUrl(URLForFile(path))
>> wor
>> }
>> ===
>>
>> to save, especially for bigger files, the memory and CPU. Nevertheless, I can't see any way how to set the MIME type; is there any trick to do that?
>>
>> Thanks,
>> OC
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden