标签:def put cat sum pen class head str utf-8
try{ HttpEntity requestEntity = new ByteArrayEntity(GzipUtil.compress(JSON.toJSONString(param),"UTF-8")); CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Content-type", "application/json; charset=UTF-8"); httpPost.setHeader("Accept", "application/json"); httpPost.setHeader("Content-Encoding", "gzip"); httpPost.setEntity(requestEntity); CloseableHttpResponse response = client.execute(httpPost); HttpEntity responseEntity = response.getEntity(); String body = null; if (responseEntity != null){ body = EntityUtils.toString(responseEntity,"UTF-8"); } EntityUtils.consume(responseEntity); response.close(); return body; }catch (Exception e){ e.printStackTrace(); }
标签:def put cat sum pen class head str utf-8
原文地址:https://www.cnblogs.com/lxk233/p/11152971.html