codecamp

easy-okhttp 为单个请求修改配置

前面也讲到了单个请求修改配置的优先级最高,但是也仅对本次请求有效。在可避免的情况下,建议将这些配置框架初始化的时候。

当我们需要对单个请求设置连接超时时间、读取超时时间等属性时,可以在执行execute方法之前调用。主要有如下几个方法可以进行调用。

  • connectTimeout(int) 连接超时时间
  • readTimeout(int) 读取超时时间
  • writeTimeout(int) 写入超时时间
  • https() 设置https证书

easy-okhttp 框架默认配置修改(代码修改法)
easy-okhttp 总结=结束
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

easy-okhttp 总结

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }