if (!compatible(p1, p2)) {
return null;
}
HTTPServerPolicy p = new HTTPServerPolicy();
if (p1.isSetCacheControl()) {
p.setCacheControl(p1.getCacheControl());
} else if (p2.isSetCacheControl()) {
p.setCacheControl(p2.getCacheControl());
}
p.setContentEncoding(combine(p1.getContentEncoding(), p2.getContentEncoding()));
p.setContentLocation(combine(p1.getContentLocation(), p2.getContentLocation()));
if (p1.isSetContentType()) {
p.setContentType(p1.getContentType());
} else if (p2.isSetContentType()) {
p.setContentType(p2.getContentType());
}
if (p1.isSetHonorKeepAlive()) {
p.setHonorKeepAlive(p1.isHonorKeepAlive());
} else if (p2.isSetHonorKeepAlive()) {
p.setHonorKeepAlive(p2.isHonorKeepAlive());
}
if (p1.isSetKeepAliveParameters()) {
p.setKeepAliveParameters(p1.getKeepAliveParameters());
} else if (p2.isSetKeepAliveParameters()) {
p.setKeepAliveParameters(p2.getKeepAliveParameters());
}
if (p1.isSetReceiveTimeout() || p2.isSetReceiveTimeout()) {
p.setReceiveTimeout(Math.min(p1.getReceiveTimeout(), p2.getReceiveTimeout()));
}
p.setRedirectURL(combine(p1.getRedirectURL(), p2.getRedirectURL()));
p.setServerType(combine(p1.getServerType(), p2.getServerType()));
if (p1.isSetSuppressClientReceiveErrors()) {
p.setSuppressClientReceiveErrors(p1.isSuppressClientReceiveErrors());
} else if (p2.isSetSuppressClientReceiveErrors()) {
p.setSuppressClientReceiveErrors(p2.isSuppressClientReceiveErrors());
}
if (p1.isSetSuppressClientSendErrors()) {
p.setSuppressClientSendErrors(p1.isSuppressClientSendErrors());
} else if (p2.isSetSuppressClientSendErrors()) {
p.setSuppressClientSendErrors(p2.isSuppressClientSendErrors());
}
return p;
}