If the invalid character exists in location header, won't redirect.

I failed at **"bad URI(is not URI?"** in the redirect.
Examine, it was because of invalid characters.
so changed to call `URI.encode`.

Best regards.