I can't because the HEAD request (after going through an authorization sequence with time delays) destroys the ability for me to subsequently retrieve the content (one connection, and then the file is "gone").
You could write the file to a temp file, parse the header, and then rename the file. As an alternative, lwpcook shows how to process a file as it arrives, so maybe you can read the header when the first chunk comes in.