retry when BadStatusLine or StatusError happens; avoided null sys.stdin.encoding