美文网首页
OkHttp有哪些优势?

OkHttp有哪些优势?

作者: 好学人 | 来源:发表于2019-06-17 12:46 被阅读0次

    Overview

    HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP efficiently makes your stuff load faster and saves bandwidth.

    OkHttp is an HTTP client that’s efficient by default:

    1. HTTP/2 support allows all requests to the same host to share a socket.
    2. Connection pooling reduces request latency (if HTTP/2 isn’t available).
    3. Transparent GZIP shrinks download sizes.
    4. Response caching avoids the network completely for repeat requests.
    5. OkHttp perseveres when the network is troublesome, it will silently recover from common connection problems.

    If your service has multiple IP addresses OkHttp will attempt alternate addresses if the first connect fails. This is necessary for IPv4+IPv6 and for services hosted in redundant data centers. OkHttp supports modern TLS features (TLS 1.3, ALPN, certificate pinning). It can be configured to fall back for broad connectivity.

    Using OkHttp is easy. Its request/response API is designed with fluent builders and immutability. It supports both synchronous blocking calls and async calls with callbacks.

    OkHttp supports Android 5.0+ (API level 21+) and Java 8+.

    参考资料

    OkHttp Overview

    相关文章

      网友评论

          本文标题:OkHttp有哪些优势?

          本文链接:https://www.haomeiwen.com/subject/hzxafctx.html