0

我尝试使用 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);
4

1 回答 1

0

答案平庸得令人失望:额外的字节是通过调用 setChunked(true) 添加的。删除调用只会发送“info”中的字节。

于 2013-01-03T22:48:15.653 回答