okhttp3设置代理(http/https)

最近项目网络请求需要设置代理,记录一下。
http和https都可以。

OkHttpClient.Builder builder = new OkHttpClient.Builder();
//代理服务器的IP和端口号
builder.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8080)));
//代理的鉴权账号密码
final String userName = "";
final String password = "";
builder.proxyAuthenticator(new Authenticator() {
         

ijkplayer设置代理和账号密码

 mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"http_proxy", "http://"+host + ":" + port);
 mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"headers", "Proxy-Authorization:"+credential);
 
 

posted @ 2021-10-20 16:51  牧之丨  阅读(6116)  评论(0编辑  收藏  举报