@Override public Response.Listener getResponseListener() { return new ForwardingResponseListener(super.getResponseListener()) { @Override public void onComplete(Result result) { HttpHeader header = getAuthenticateHeader(); HttpFields headers = result.getResponse().getHeaders(); // There is no need to check for a SPNEGO token because it can't exist here: // * SPNEGO token only exist if the client successfully authenticated // * This authenticate handler is not called when already authenticated if (headers.getValuesList(header).stream().anyMatch(NEGOTIATE::equalsIgnoreCase)) { headers.put(header, NEGOTIATE + " realm=\"dummy\""); } super.onComplete(result); } }; } }
@Override protected void doStart() throws Exception { if (executor == null) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); setExecutor(threadPool); } if (byteBufferPool == null) setByteBufferPool(new MappedByteBufferPool(2048, executor instanceof ThreadPool.SizedThreadPool ? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2 : ProcessorUtils.availableProcessors() * 2)); if (scheduler == null) setScheduler(new ScheduledExecutorScheduler(name + "-scheduler", false)); if (resolver == null) setSocketAddressResolver(new SocketAddressResolver.Async(executor, scheduler, getAddressResolutionTimeout())); handlers.put(new ContinueProtocolHandler()); handlers.put(new RedirectProtocolHandler(this)); handlers.put(new WWWAuthenticationProtocolHandler(this)); handlers.put(new ProxyAuthenticationProtocolHandler(this)); decoderFactories.add(new GZIPContentDecoder.Factory(byteBufferPool)); cookieManager = newCookieManager(); cookieStore = cookieManager.getCookieStore(); transport.setHttpClient(this); super.doStart(); }