我尝试使用 ByteArrayEntity,如下所示,但这会发送不在协议缓冲区本身中的额外字节。是否有仅发布内容的实体?
byte [] info;
... [info initialized] ...
HttpPost httppost = new HttpPost("https://myurl");
ByteArrayEntity reqEntity = new ByteArrayEntity(info);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true);
httppost.setEntity(reqEntity);
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);