Re: Getting the right content type for cached objects

Hello Thorsten,

In our previous episode, Thorsten Conradi conradi@kidata.de said:
> 
> I encounter the follwing problem (bug?)
> My application makes simple http requests and uses
> a cache. When I get the document via http, the
> mime-type is OK, but when I get the document from
> cache, the content-type is set to www/unkown.
>
> Some IMPORTANT details:
>
> - In the cache-meta-file, the content is set correctly
> - I use the method (in the afterFilter)
>
>       HTResponse_format(pResponse);
>
>   to get the (wrong) type.
> - When I use
>
>       HTAnchor_format(HTAnchor_parent(m_pHTAnchor));
>
>   I get the right type.
>
>
> My conclusion:
>
> Either the use of HTResponse_format(pResponse) is not
> well defined in the context of cached objects and I'm only
> to dum to find it in the docu or there might be a bug...

Yes, it is a bug. I have the same problem. When you get something from the
cache, the HTResponse object is not initialized using the headers found
in the the cache. These headers are only copied to the HTAnchor object.

I'm going to write a function to copy the headers to the response object
when the cache calls CacheCleanup() with a HT_NOT_MODIFIED status.

I just patched Amaya so that if if finds an HTResponse with content-type
unknown, it'll then try to get the content-type from the anchor object.
Of course, the best safe solution is to get it from HTResponse and not do
these patches :)

-jose

Received on Wednesday, 13 December 2000 06:06:45 UTC