我已尝试使用ByteArrayEntity,如下所示,但这会发送不在协议缓冲区本身的额外字节。是否只有POST内容的实体?
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);
答案 0 :(得分:0)
答案是令人失望的平庸:通过调用setChunked(true)添加了额外的字节。删除呼叫只会导致“info”中的字节被发送。