public byte[] post(String url,byte[] bytes) throws Exception { HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new ByteArrayEntity(bytes)); httpPost.setHeader("Content-type", "application/octet-stream;charset=UTF-8"); //这里是设置虚拟IP String remoteIp = (int) (Math.random() * 255 + 1)+"."+(int) (Math.random() * 255 + 1)+"."+(int) (Math.random() * 255 + 1)+"."+(int) (Math.random() * 255 + 1); httpPost.setHeader("X-Forwarded-For",remoteIp); CloseableHttpResponse httpResponse = HttpClients.createDefault().execute(httpPost); try { HttpEntity entityResponse = httpResponse.getEntity(); int responseCode = httpResponse.getStatusLine().getStatusCode(); int contentLength = (int) entityResponse.getContentLength(); // OutputStream out = new By
使用httpPost发送 字节流请求 byte[]
最新推荐文章于 2024-06-07 23:34:50 发布