/** * Follows a redirect. * @param httpSession * @param session * @return * @throws URISyntaxException */ private DefaultConnectFuture followRedirect(DefaultHttpSession httpSession, IoSessionEx session) throws URISyntaxException { HashMap<ResourceOption<?>, Object> overrides = new HashMap<>(); // fix redirects Integer maxRedirects = new Integer((httpSession.getRemoteAddress().getOption(MAXIMUM_REDIRECTS)) - 1); overrides.put(MAXIMUM_REDIRECTS, maxRedirects); // fix location URI newLocation = new URI(httpSession.getReadHeader("location")); URI oldLocation = httpSession.getRequestURL(); newLocation = resolveFragement(newLocation, oldLocation); if (!newLocation.isAbsolute()) { newLocation = URLUtils.modifyURIPath(oldLocation, newLocation.getPath()); } String oldQuery = oldLocation.getQuery(); if (oldQuery != null && appendQueryWhenFollowingRedirect) { newLocation = URLUtils.modifyURIQuery(newLocation, oldQuery); } httpSession.setRequestURI(URLUtils.getPathAndQueryURI(newLocation)); ResourceAddress newConnectAddress = addressFactory.newResourceAddress(newLocation.toString(), new WrappedResourceOptionsForConnectionRetry(httpSession, overrides)); return retryConnect(httpSession, session, newConnectAddress); }
String contentLengthStr = session.getReadHeader("Content-Length"); if (contentLengthStr != null && !"0".equals(contentLengthStr)) { IoBufferAllocatorEx<? extends HttpBuffer> allocator = session.getBufferAllocator();
/** * Attempts authentication to a http address. * @param httpSession * @param session * @param challengeToCredentials * @param proxy * @return */ private DefaultConnectFuture authenticate(DefaultHttpSession httpSession, IoSessionEx session, String authorizationValue, RequestorType requestorType) { String location = httpSession.getRemoteAddress().getExternalURI(); HashMap<ResourceOption<?>, Object> overrides = new HashMap<>(); Integer maxAthenticates = new Integer((httpSession.getRemoteAddress().getOption(MAX_AUTHENTICATION_ATTEMPTS)) - 1); overrides.put(MAX_AUTHENTICATION_ATTEMPTS, maxAthenticates); ResourceAddress newConnectAddress = addressFactory.newResourceAddress(location.replaceFirst("ws", "http"), new WrappedResourceOptionsForConnectionRetry(httpSession, overrides)); if (RequestorType.SERVER.equals(requestorType)) { httpSession.setWriteHeader(HEADER_AUTHORIZATION, authorizationValue); } else { httpSession.setWriteHeader(HEADER_PROXY_AUTHORIZATION, authorizationValue); } final String challengeIdentity = httpSession.getReadHeader(HEADER_SEC_CHALLENGE_IDENTITY); if (challengeIdentity != null) { httpSession.setWriteHeader(HEADER_SEC_CHALLENGE_IDENTITY, challengeIdentity); } return retryConnect(httpSession, session, newConnectAddress); }
String contentLengthStr = httpSession.getReadHeader("Content-Length"); if ( contentLengthStr != null && !"0".equals(contentLengthStr)) { if(httpSession.getFilterChain().contains(HttpAcceptFilter.CODEC.filterName())) {