An awkward API OkHttp 1.0 started out as an optimized implementation of HttpURLConnection. This old API is awkward to implement because there is an implicit state machine that corresponds to the underlying network I/O. GET / HTTP/1.1 Host: publicobject.com Accept: text/html HTTP/1.1 200 OK Content-Length: 300 <html> <head><title>Public Object</title></head> ... For example, calling getResponseCode
OkHttp exposes three APIs: Request/Response. This is the most fully-featured API. It can be used synchronously or asynchronously. It avoids mutable state. Plus interceptors! OkUrlFactory, the HttpURLConnection API. This is a complete implementation of an awkward API. The API’s awkardness has resulted in an implementation that is complex and fragile. The Apache HTTP client shim. This is intended to
はじめに AndroidのRESTクライアントのネットワーク処理と非同期処理について、Volley + Gsonの組み合わせでAsyncTask or AsyncLoaderで別スレッドを作って通信して結果を取得してJSONをパースしていたりしていましたが今の流行りはOkHTTP + retorofit + RxAndroidのようなので試してみたいと思います。 本記事のゴール 無料のlivedoor 天気情報APIを使ってデータを受け取る部分までをやりたいと思います。 APIの詳細は以下をご確認ください http://weather.livedoor.com/weather_hacks/ 環境 Android studio 1.4 OkHTTP:HTTP クライアント用のライブラリ Retrofit:REST クライアント用のライブラリ RxAndroid:リアクティブプログラミングを
okhttpのドキュメントはあまりないのだけど、wikiのrecipe集がそこそこ揃っている。 Recipes · square/okhttp Wiki · GitHub 実際に動くコードははsamples moduleにあるのでcloneするとIDEで見ることができる。 square/okhttp/samples/com.squareup.okhttp.recipes ちなみにokhttpの一部であるMockWebServerはあまり注目されていないけど強力だ。Mockitoを駆使してWeb API Clientのテストを書くよりもずっと信頼できるし、原理的にも分かりやすい。 okhttp/mockwebserver at master · square/okhttp · GitHub
OkHttp changes the global SSL context, breaks other HTTP clients Workaround 全部OkHttpClientで書き換える → 外部ライブラリには不可能 URL.setURLStreamHandlerFactory(new OkHttpClient()); → Apache Http Clientには効かない OkHttpClientを使う前にこのコードを追加する OkHttpを外す 結局手間を考えて最後のオプションを採りました(´・ω・`) 追記 AOSPにバグ登録されてた Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back u
This talk will be an in-depth look at Okio—a tiny library for interacting with bytes—and a few of the libraries written on top of it: OkHttp, Retrofit, and a newcomer named Moshi. Okio evolved naturally inside of OkHttp before being split out into its own library. It wraps common patterns behind a friendly API for reading, writing, and processing data. We'll start with some fundamentals of the lib
海外向けのAndroidアプリを開発している @rejasupotaro です。 4/12、13にDroidcon ItalyというAndroidのカンファレンスがありました。 Droidcon Italy 2015 私はそのカンファレンスでパフォーマンスの話をしてきました。この記事の前半では、カンファレンスで発表したパフォーマンスの話を、後半に海外のカンファレンスに参加してみてどうだったかということを書きます。 パフォーマンスの話 以下のような3部構成で話をしました。 HTTPと通信を行う環境 画像の読み込みと最適化 UXを高めるAPI設計 以降の記事はスライドの補足が主になりますので、スライドを一読したあとに読み進めていただくとより実りがあると思います。 HTTP通信を見直す 通信の中身を見る まず、通信を見ることができるようにします。以前は mitmproxy や Charles な
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く