httpMethod.addHeader(Constants.HDR_VCLOCK, vclock);
}
// Serialize body
if (httpMethod instanceof HttpEntityEnclosingRequestBase) {
HttpEntityEnclosingRequestBase entityEnclosingMethod = (HttpEntityEnclosingRequestBase) httpMethod;
AbstractHttpEntity entity = null;
// Any value set using setValueAsStream() has precedent over value
// set using setValue()
if (valueStream != null) {
if (valueStreamLength != null && valueStreamLength >= 0) {
entity = new InputStreamEntity(valueStream, valueStreamLength);
} else {
// since apache http client 4.1 no longer supports buffering stream entities, but we can't change API
// behaviour, here we have to buffer the whole content
entity = new ByteArrayEntity(ClientUtils.bufferStream(valueStream));
}
} else if (value != null) {
entity = new ByteArrayEntity(value);
} else {
entity = new ByteArrayEntity(EMPTY);
}
entity.setContentType(contentType);
entityEnclosingMethod.setEntity(entity);
}
}