js: Fix crash when doing HEAD request