时间:2021-07-01 10:21:17 帮助过:13人阅读
java
String body = "Lorem ipsum shizzle ma nizle"; URL url = new URL("http://some.url/file.php?id=" + uid); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setRequestProperty("Content-encoding", "deflate"); conn.setRequestProperty("Content-type", "application/octet-stream"); DeflaterOutputStream dos = new DeflaterOutputStream(conn.getOutputStream()); dos.write(body.getBytes()); dos.flush(); dos.close();
php
$content = http_get_request_body();$uncontent = gzuncompress($content);
二、ios与php的交互
php接收gzip压缩
gzdecode(base64_decode($json));//ios gzip uncompress
php接收zlib压缩
gzuncompress(base64_decode($json));//ios zlib uncompress