improve redirect, add max_redirects

Signed-off-by: Jack <jack.wgm@gmail.com>