String mimeType = (String) type[0];
Charset charset = (Charset) type[1];
if (request.hasBody()) {
InputStream stream = ((SenderBodyRequest) request).getBodyStream();
if (stream instanceof FakeStream) {
FakeStream fake = (FakeStream) stream;
if (fake.getValue() instanceof String) {
String string = (String) fake.getValue();
byte[] dataBytes = string.getBytes(charset);
writeBytes(connection, dataBytes);
} else {
RequestBodyMarshaller marshaller = getRequestMarshaller(mimeType);
if (marshaller == null) {
throw new IllegalArgumentException("Request body marshaller not found for " + mimeType);
}
if (fake.isStreaming()) {
marshaller.write(fake.getValue(), connection.getOutputStream(), charset);
} else {
//XXX create string first an then write...
marshaller.write(fake.getValue(), connection.getOutputStream(), charset);
}
}
} else {
writeStream(connection, stream);
}