}
private synchronized HttpProcessor getProtocolProcessor() {
if (protocolProcessor == null) {
// Get mutable HTTP processor
final BasicHttpProcessor proc = getHttpProcessor();
// and create an immutable copy of it
final int reqc = proc.getRequestInterceptorCount();
final HttpRequestInterceptor[] reqinterceptors = new HttpRequestInterceptor[reqc];
for (int i = 0; i < reqc; i++) {
reqinterceptors[i] = proc.getRequestInterceptor(i);
}
final int resc = proc.getResponseInterceptorCount();
final HttpResponseInterceptor[] resinterceptors = new HttpResponseInterceptor[resc];
for (int i = 0; i < resc; i++) {
resinterceptors[i] = proc.getResponseInterceptor(i);
}
protocolProcessor = new ImmutableHttpProcessor(reqinterceptors, resinterceptors);
}
return protocolProcessor;
}