Use xhr 2.0.0 interface correctly, and handle retries properly

@redonkulus @mridgway @lingyan