1
HttpClient httpClient = new DefaultHttpClient();
         HttpContext localContext = new BasicHttpContext();
         HttpPut put = new HttpPut("url");
         put.addHeader("X-Apikey","");
         StringEntity se = new StringEntity( version.toString());  
         se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
         put.addHeader("Accept", "application/json");
         put.addHeader("Content-type", "application/json");
         put.setEntity(se);


         try{

               HttpResponse response = httpClient.execute(put, localContext);
               HttpEntity entity = response.getEntity();

在这里,我需要帮助将 HttpClient 替换为 OkHttpClient 及其所有后续参数。

4

1 回答 1

0

okhttp -apache模块让你这样做:

HttpClient httpClient = new OkApacheClient();

它不能做 Apache HTTP 客户端可以做的所有事情,但它确实使迁移更容易。

于 2014-02-27T12:41:56.263 回答