I often get lines like this in my Apache error log:
File does not exist: /path/to/www/data:image/gif;base64,R0lGODlhBgAGAIAOAP/yH5BAEACAEALAAAAAAGGAYAAAIJhB0Xi5vOoFwFADs=
Obviously, this is due to somebody using an outdated browser (or a robot) which doesn't handle inline images (Data URI/base64 encoded).
I am thinking it must be easy to redirect requests starting with "data:image/gif;base64,"
to a short perl CGI script which returns the requested value as a binary image, with the correct content header (both GIFs and PNGs are used), and without having to read any image files.
I am thinking something along the lines of the following CGI (after a rewrite places the request URL in the query string):
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Base64 ();
$ENV{QUERY_STRING} =~ m{^data:(\w+/\w+);base64,(.+)$} or die "bad input";
print "Content-Type: $1\n\n";
print MIME::Base64::decode ($2);
Would that work and would there be any downsides to this approach (apart from accommodating people with last-century browsers)?