fix broken Location: headers by being more robust like a real browser