Skip to content

2019-11-21:谈谈网络请求中的拦截器(Interceptor)? #193

Open

Description

@MoJieBlog
No description provided.

Activity

  1. changed the title [-]2019-11-21:谈谈网络请求中的拦截器(Intercept)?[/-] [+]2019-11-21:谈谈网络请求中的拦截器(Interceptor)?[/+] on Nov 21, 2019
  2. Moosphan commented on Nov 21, 2019

    @Moosphan
    Owner

    以okhttp为例,可以谈谈它内部拦截器的工作原理和应用场景

  3. hy20160705 commented on Nov 26, 2019

    @hy20160705

    在OkHttp中 它内部拦截器采用了责任链的模式 如重试拦截器(请求重试)=>请求头拦截器(修改请求头信息)等 在我们View的事件传递机制中也用了责任链的模式 只能讲个泛泛 等待大佬补充

  4. yline commented on Mar 1, 2020

    @yline

    系统自带的拦截器:
    1,重试和重定向
    2,请求头+响应头处理
    3,缓存
    4,dns + 三次握手
    5,CallServer,读写数据流

    常用的自定义拦截器:
    1,日志拦截器
    2,自定义缓存规则拦截器
    3,重试机制等等

  5. aositeluoke commented on Dec 24, 2020

    @aositeluoke

    RetryAndFollowUpInterceptor:负责失败重试以及重定向。
    BridgeInterceptor:负责把用户构造的请求转换为发送给服务器的请求,把服务器返回的响应转换为对用户友好的响应。
    CacheInterceptor:负责读取缓存以及更新缓存。
    ConnectInterceptor:负责与服务器建立连接。
    CallServerInterceptor:负责从服务器读取响应的数据。

  6. mlinqirong commented on Dec 30, 2021

    @mlinqirong

    okhttp Interceptor拦截器实现请求和响应拦截 采用责任链模式 用于重试 重写拦截请求机制
    可应用于请求日志拦截 重写请求头 重写参数 缓存等拦截处理

  7. senlinxuefeng commented on Jan 17, 2022

    @senlinxuefeng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions