set referer based on path and don't create output file until the request works