Bug 41475 - mod_cache does not serve (CACHE_OUT) URLs which are url-escaped
Summary: mod_cache does not serve (CACHE_OUT) URLs which are url-escaped
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cache (show other bugs)
Version: 2.2.4
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
: 41516 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-26 06:27 UTC by Lars Uffmann
Modified: 2007-05-17 14:20 UTC (History)
1 user (show)



Attachments
Patch against trunk (2.47 KB, patch)
2007-02-06 06:49 UTC, Ruediger Pluem
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Uffmann 2007-01-26 06:27:38 UTC
Max OS X, Linux, Solaris
Apache: 2.2.4

When an object is cached who's URL is url-escaped (containg spaces, etc),
mod_cache will never serve the cached file because the key-lookup to locate
the cached file is performed using the escaped URL. Instead the file is
cached over and over again, using the unescaped URL as the key.

PS: I added the ap_log_error to cache_generate_key_default() in cache_storage.c

Test-config:

<Location /tmc/>
  ExpiresActive On
  ExpiresDefault A31536000
</Location>
CacheEnable disk /tmc/
...

# mkdir -p htpdocs/tmc
# cp /etc/hosts htdocs/tmc/bla.txt 
# cp /etc/hosts htdocs/tmc/foo\ bar.txt

This problem is quite similar in effect to #40805.

# curl -D - -o /dev/null 'http://localhost/tmc/foo%20bar.txt'

request #1

Fri Jan 26 14:41:16 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/foo%20bar.txt?'
[Fri Jan 26 14:41:16 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE filter for /tmc/foo%
20bar.txt
[Fri Jan 26 14:41:16 2007] [debug] mod_cache.c(136): Adding CACHE_REMOVE_URL filter for /tmc/foo%
20bar.txt
[Fri Jan 26 14:41:16 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/foo bar.txt?'
[Fri Jan 26 14:41:16 2007] [debug] mod_cache.c(609): cache: Caching url: /tmc/foo%20bar.txt
[Fri Jan 26 14:41:16 2007] [debug] mod_cache.c(615): cache: Removing CACHE_REMOVE_URL filter.
[Fri Jan 26 14:41:16 2007] [debug] mod_cache.c(658): cache: Added date header
[Fri Jan 26 14:41:16 2007] [debug] mod_disk_cache.c(954): disk_cache: Stored headers for URL http://
localhost:80/tmc/foo bar.txt?
[Fri Jan 26 14:41:16 2007] [debug] mod_disk_cache.c(1043): disk_cache: Body for URL http://localhost:
80/tmc/foo bar.txt? cached.


request #2

[Fri Jan 26 14:41:44 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/foo%20bar.txt?'
[Fri Jan 26 14:41:44 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE filter for /tmc/foo%
20bar.txt
[Fri Jan 26 14:41:44 2007] [debug] mod_cache.c(136): Adding CACHE_REMOVE_URL filter for /tmc/foo%
20bar.txt
[Fri Jan 26 14:41:44 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/foo bar.txt?'
[Fri Jan 26 14:41:44 2007] [debug] mod_cache.c(609): cache: Caching url: /tmc/foo%20bar.txt
[Fri Jan 26 14:41:44 2007] [debug] mod_cache.c(615): cache: Removing CACHE_REMOVE_URL filter.
[Fri Jan 26 14:41:44 2007] [debug] mod_cache.c(658): cache: Added date header
[Fri Jan 26 14:41:44 2007] [debug] mod_disk_cache.c(954): disk_cache: Stored headers for URL http://
localhost:80/tmc/foo bar.txt?
[Fri Jan 26 14:41:44 2007] [debug] mod_disk_cache.c(1043): disk_cache: Body for URL http://localhost:
80/tmc/foo bar.txt? cached.


# curl -D - -o /dev/null 'http://localhost/tmc/bla.txt' 

request #1
[Fri Jan 26 14:44:21 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/bla.txt?'
[Fri Jan 26 14:44:21 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE filter for /tmc/bla.txt
[Fri Jan 26 14:44:21 2007] [debug] mod_cache.c(136): Adding CACHE_REMOVE_URL filter for /tmc/
bla.txt
[Fri Jan 26 14:44:21 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/bla.txt?'
[Fri Jan 26 14:44:21 2007] [debug] mod_cache.c(609): cache: Caching url: /tmc/bla.txt
[Fri Jan 26 14:44:21 2007] [debug] mod_cache.c(615): cache: Removing CACHE_REMOVE_URL filter.
[Fri Jan 26 14:44:21 2007] [debug] mod_cache.c(658): cache: Added date header
[Fri Jan 26 14:44:21 2007] [debug] mod_disk_cache.c(954): disk_cache: Stored headers for URL http://
localhost:80/tmc/bla.txt?
[Fri Jan 26 14:44:21 2007] [debug] mod_disk_cache.c(1043): disk_cache: Body for URL http://localhost:
80/tmc/bla.txt? cached.

request #2
[Fri Jan 26 14:44:43 2007] [debug] cache_storage.c(432): cache_generate_key_default(): key is 'http://
localhost:80/tmc/bla.txt?'
[Fri Jan 26 14:44:43 2007] [debug] mod_disk_cache.c(477): disk_cache: Recalled cached URL info 
header http://localhost:80/tmc/bla.txt?
[Fri Jan 26 14:44:43 2007] [debug] mod_disk_cache.c(750): disk_cache: Recalled headers for URL 
http://localhost:80/tmc/bla.txt?
[Fri Jan 26 14:44:43 2007] [info] Incoming request is asking for a uncached version of /tmc/bla.txt, but 
we know better and are ignoring it
[Fri Jan 26 14:44:43 2007] [debug] mod_cache.c(263): cache: running CACHE_OUT filter
[Fri Jan 26 14:44:43 2007] [debug] mod_cache.c(277): cache: serving /tmc/bla.txt
Comment 1 Ruediger Pluem 2007-02-01 12:47:38 UTC
*** Bug 41516 has been marked as a duplicate of this bug. ***
Comment 2 Ruediger Pluem 2007-02-06 06:49:05 UTC
Could you please give the attached patch a try and report back whether it solves
your problem?
Comment 3 Ruediger Pluem 2007-02-06 06:49:38 UTC
Created attachment 19529 [details]
Patch against trunk
Comment 4 Lars Uffmann 2007-02-06 07:28:45 UTC
(In reply to comment #2)
> Could you please give the attached patch a try and report back whether it solves
> your problem?

I applied your patch against 2.2.4.

The testcase I used to report the problem (see above) worked for me.
Comment 5 Dean Scothern 2007-02-12 06:48:51 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > Could you please give the attached patch a try and report back whether it solves
> > your problem?
> 
> I applied your patch against 2.2.4.
> 
> The testcase I used to report the problem (see above) worked for me.

Confirming that this solved my problems also (duplicate reported bug 41516),
when applied to 2.2.4.
Comment 6 Ruediger Pluem 2007-02-12 12:30:12 UTC
Thanks for the feedback. Committed to trunk as r506621
(http://svn.apache.org/viewvc?view=rev&revision=506621).
Comment 7 Ruediger Pluem 2007-05-17 14:20:11 UTC
Backported to 2.2.x as r539112 (http://svn.apache.org/viewvc?view=rev&rev=539112).