Check for error from HEAD request in `copy_doc`

Ref #165.