Retrofit parent-2.2.0 發布,一個類型安全的Java和Android 的REST客戶端庫

jopen 7年前發布 | 17K 次閱讀 Retrofit HTTP Android Java REST JSON XML

 

Retrofit是Square公司開發的一個類型安全的Java和Android 的REST客戶端庫,這個庫為網絡認證、API請求以及用OkHttp發送網絡請求提供了強大的框架 。Retrofit 庫使得從web api下載JSON 或者xml數據變的非常簡單直接,一旦數據下載完成即將其解析成普通java類(POJO)。

Retrofit特點 :

  • 底層使用OkHttp進行網絡傳輸,性能好,速度快;
  • 擁有出色的API文檔和社區支持 ;
  • 可以自動將REST API返回的數據轉化為Java對象,且支持多種數據轉換格式(如json、xml等) ;
  • 使用Java注解聲明HTTP請求 ;
  • 支持 Multipart請求和文件上傳;

更新日志

  • RxJava 2.x is now supported with a first-party 'adapter-rxjava2' artifact.
  • New: @QueryName annotation allows creating a query parameter with no '=' separator or value.
  • New: Support for messages generated by Protobuf 3.0 or newer when using the converter for Google's protobuf.
  • New: RxJava 1.x call adapter now correctly handles broken subscribers whose methods throw exceptions.
  • New: Add toString() implementations for Response and Result.
  • New: The Moshi converter factory now offers methods for enabling null serialization and lenient parsing.
  • New: Add createAsync() to RxJava 1.x call adapter factory which executes requests using Call.enqueue() using the underlying HTTP client's asynchronous support.
  • New: NetworkBehavior now allows setting an error percentage and returns HTTP errors when triggered.
  • HttpException has been moved into the main artifact and should be used instead of the versions embedded in each adapter (which have been deprecated).
  • Promote the response body generic type on CallAdapter from the adapt method to the enclosing class. This is a source-incompatible but binary-compatible change which is only relevant if you are implementing your own CallAdapters.
  • Remove explicit handling of the now-defunct RoboVM platform.
  • Fix: Close response on HTTP 204 and 205 to avoid resource leak.
  • Fix: Reflect the canceled state of the HTTP client's Call in Retrofit's Call.
  • Fix: Use supplied string converters for the String type on non-body parameters. This allows user converters to handle cases such as when annotating string parameters instead of them always using the raw string.
  • Fix: Skip a UTF-8 BOM (if present) when using the converter for Moshi.

下載

本站原創,轉載時保留以下信息:
本文轉自:深度開源(open-open.com)
原文地址:http://www.baiduhome.net/news/view/479d0bb6

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!