protected void flushHeaders() throws IOException {
if (headersFlushed)
return;
headersFlushed = true;
RuntimeDelegate delegate = RuntimeDelegate.getInstance();
for (String key : headers.keySet()) {
List<Object> objs = headers.get(key);
for (Object obj : objs) {
String value;
RuntimeDelegate.HeaderDelegate headerDelegate = delegate
.createHeaderDelegate(obj.getClass());
if (headerDelegate != null) {
value = headerDelegate.toString(obj);
} else {
value = obj.toString();