use of cz.msebera.android.httpclient.message.BasicHttpRequest in project Zom-Android by zom.
the class OtrDataHandler method sendRequest.
private void sendRequest(Request request) {
MemorySessionOutputBuffer outBuf = new MemorySessionOutputBuffer();
HttpMessageWriter writer = new HttpRequestWriter(outBuf, lineFormatter, params);
HttpMessage req = new BasicHttpRequest(request.method, request.url, PROTOCOL_VERSION);
String uid = UUID.randomUUID().toString();
req.addHeader("Request-Id", uid);
if (request.headers != null) {
for (Entry<String, String> entry : request.headers.entrySet()) {
req.addHeader(entry.getKey(), entry.getValue());
}
}
try {
writer.write(req);
outBuf.write(request.body);
outBuf.flush();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (HttpException e) {
throw new RuntimeException(e);
}
byte[] data = outBuf.getOutput();
Message message = new Message("");
message.setFrom(request.us);
message.setTo(request.them);
if (req.containsHeader("Range"))
debug("send request " + request.method + " " + request.url + " " + req.getFirstHeader("Range"));
else
debug("send request " + request.method + " " + request.url);
requestCache.put(uid, request);
mChatSession.sendDataAsync(message, false, data);
}
Aggregations