Support HEAD requests. Fixes #1021.