private Header[] doFormatOneHeader(final Cookie[] cookies) {
int version = Integer.MAX_VALUE;
// Pick the lowerest common denominator
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
if (cookie.getVersion() < version) {
version = cookie.getVersion();
}
}
CharArrayBuffer buffer = new CharArrayBuffer(40 * cookies.length);
buffer.append(SM.COOKIE);
buffer.append(": ");
formatParamAsVer(buffer, "$Version", Integer.toString(version), version);
for (int i = 0; i < cookies.length; i++) {
buffer.append("; ");
Cookie cookie = cookies[i];
formatCookieAsVer(buffer, cookie, version);
}
return new Header[] { new BufferedHeader(buffer) };
}