{"id":965,"date":"2023-03-11T19:44:14","date_gmt":"2023-03-11T11:44:14","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=965"},"modified":"2023-04-29T13:28:54","modified_gmt":"2023-04-29T05:28:54","slug":"resolve-okhttp-error-with-java-lang-illegalstateexception-closed","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/11\/resolve-okhttp-error-with-java-lang-illegalstateexception-closed\/","title":{"rendered":"\u89e3\u51b3OKHttp\u62a5java.lang.IllegalStateException closed"},"content":{"rendered":"<p>\u539f\u56e0\uff1aOkHttp\u8bf7\u6c42\u56de\u8c03\u4e2d<code>response.body().string()<\/code>\u53ea\u80fd\u6709\u6548\u8c03\u7528\u4e00\u6b21<\/p>\n<p>\u5728\u8c03\u7528<code>response.body().string()<\/code>\u65b9\u6cd5\u4e4b\u540e\uff0cresponse\u4e2d\u7684\u6d41\u5c31\u4f1a\u88ab\u5173\u95ed\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u521b\u5efa\u51fa\u4e00\u4e2a\u65b0\u7684response\u7ed9\u5e94\u7528\u5c42\u5904\u7406\u3002<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">@Override\npublic Response intercept(Chain chain) throws IOException {\n    Request request = chain.request();\n    logForRequest(request);\n    Response response = chain.proceed(request);\n    MediaType mediaType = response.body().contentType();\n    String content = response.body().string();\n    Log.i(TAG, content);\n    return response.newBuilder()\n            .body(ResponseBody.create(mediaType, string))\n            .build();\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u56e0\uff1aOkHttp\u8bf7\u6c42\u56de\u8c03\u4e2dresponse.body().string()\u53ea\u80fd\u6709\u6548\u8c03\u7528\u4e00\u6b21 \u5728\u8c03\u7528respo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[116],"tags":[],"class_list":["post-965","post","type-post","status-publish","format-standard","hentry","category-okhttp"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=965"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/965\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}