private static Charset charsetOrDefault(Charset charset) { return withDefault(charset, DEFAULT_CHARSET); }
private void updateCharset() { String contentTypeHeader = headers.get(CONTENT_TYPE); Charset contentTypeCharset = extractContentTypeCharsetAttribute(contentTypeHeader); charset = withDefault(contentTypeCharset, withDefault(charset, UTF_8)); if (contentTypeHeader != null && contentTypeHeader.regionMatches(true, 0, "text/", 0, 5) && contentTypeCharset == null) { // add explicit charset to content-type header headers.set(CONTENT_TYPE, contentTypeHeader + "; charset=" + charset.name()); } }
private static String computeContentType(String contentType, String fileName) { return contentType != null ? contentType : MIME_TYPES_FILE_TYPE_MAP.getContentType(withDefault(fileName, "")); }
@Override public String getResponseBody() { return getResponseBody(withDefault(extractContentTypeCharsetAttribute(getContentType()), UTF_8)); }
private void kerberosChallenge(Realm realm, Request request, HttpHeaders headers) throws SpnegoEngineException { Uri uri = request.getUri(); String host = withDefault(request.getVirtualHost(), uri.getHost()); String challengeHeader = SpnegoEngine.instance(realm.getPrincipal(), realm.getPassword(), realm.getServicePrincipalName(), realm.getRealmName(), realm.isUseCanonicalHostname(), realm.getCustomLoginConfig(), realm.getLoginContextName()).generateToken(host); headers.set(AUTHORIZATION, NEGOTIATE + " " + challengeHeader); } }
public SimpleAsyncHttpClient build() { if (realmBuilder != null) { configBuilder.setRealm(realmBuilder.build()); } if (proxyHost != null) { Realm realm = null; if (proxyPrincipal != null) { AuthScheme proxyAuthScheme = withDefault(this.proxyAuthScheme, AuthScheme.BASIC); realm = realm(proxyAuthScheme, proxyPrincipal, proxyPassword).build(); } configBuilder.setProxyServer(proxyServer(proxyHost, proxyPort).setRealm(realm).build()); } configBuilder.addIOExceptionFilter(new ResumableIOExceptionFilter()); SimpleAsyncHttpClient sc = new SimpleAsyncHttpClient(configBuilder.build(), requestBuilder, defaultThrowableHandler, errorDocumentBehaviour, enableResumableDownload, ahc, listener); return sc; } }