Image Negotiation
Image negotiation is a special corner of general content negotiation because the Web has a variety of image files with different levels of support: for instance, some browsers can cope with PNG files and some can’t, and the latter have to be sent the simpler, more old-fashioned, and bulkier GIF files. The client’s browser sends a message to the server telling it which image files it accepts:
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Browsers almost always lie about the content types they accept or prefer, so this may not be all that reliable. In theory, however, the server uses this information to guide its search for an appropriate file, and then it returns it. We can demonstrate the effect by editing our ... /htdocs/catalog_summer.html file to remove the .jpg extensions on the image files. The appropriate lines now look like this:
... <img src="bench" alt="Picture of a Bench"> ... <img src="hen" alt="Picture of a hencoop like a pagoda"> ...
When Apache has the Multiviews
option turned on
and is asked for an image called bench, it looks
for the smaller of bench.jpg and
bench.gif — assuming the
client’s browser accepts both — and returns it.
Apache v2 introduces a new directive, which is related to the Filter mechanism (see later in this chapter, Section 6.6).
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.