Capture the user-agent

Fixes a bug in the changes in f5d8b56e.