public static URI getRequestURI(URI requestURI, String hostHeader, IoSession session) { boolean secure = SslUtils.isSecure(session); String authority = HttpUtils.getHostAndPort(hostHeader, secure); // Use getRawPath to get the un-decoded path; getPath returns the post-decode value. // This is required to handle special characters like spaces in the URI (KG-831). URI uri = URI.create("//" + authority + requestURI.getRawPath()); return uri; }
@Override protected DecodingState initDecodingState(IoSession session) { IoSessionEx sessionEx = (IoSessionEx) session; IoBufferAllocatorEx<?> allocator = sessionEx.getBufferAllocator(); return new HttpRequestDecodingState(allocator, SslUtils.isSecure(session)); }
public static URI getTransportURI(HttpRequestMessage request, IoSession session) { URI requestURI = request.getRequestURI(); String hostHeader = request.getHeader("Host"); boolean secure = SslUtils.isSecure(session); String authority = HttpUtils.getHostAndPort(hostHeader, secure); // Use getRawPath to get the un-decoded path; getPath returns the post-decode value. // This is required to handle special characters like spaces in the URI (KG-831). return URI.create("http://" + authority + requestURI.getRawPath()); }
@SuppressWarnings("deprecation") private DefaultHttpSession(IoServiceEx service, IoProcessorEx<DefaultHttpSession> processor, ResourceAddress address, ResourceAddress remoteAddress, IoSessionEx parent, IoBufferAllocatorEx<HttpBuffer> allocator, Direction direction, Properties configuration) { super(service, processor, address, remoteAddress, parent, allocator, direction); writeHeaders = new LinkedHashMap<>(); writeCookies = new HashSet<>(); status = direction == Direction.READ ? HttpStatus.SUCCESS_OK : null; reason = null; secure = SslUtils.isSecure(parent); committing = new AtomicBoolean(false); connectionClose = new AtomicBoolean(false); shutdownWrite = new AtomicBoolean(false); upgradeFuture = new DefaultUpgradeFuture(parent); commitFuture = new DefaultCommitFuture(this); responseFuture = direction == Direction.READ ? null : new DefaultResponseFuture(this); httpxeSpecCompliant = configuration == null ? false : HTTPXE_SPECIFICATION.getBooleanProperty(configuration); // TODO: add and use new HttpResourceAddress "maximum.redirects" option of type Integer, default 5 //redirectsAllowed = ((HttpResourceAddress) remoteAddress).getOption(HttpResourceAddress.MAXIMUM_REDIRECTS); redirectsAllowed = 0; }
public IoSessionEx setParent(IoSessionEx newParent){ this.setLocalAddress(LOCAL_ADDRESS.get(newParent)); // newParent.getRemoteAddress(); httpSession.setLocalAddress((ResourceAddress)redirectRemoteAddress); upgradeFuture.setSession(newParent); if (!SslUtils.isSecure(newParent) && secure) { throw new InvalidParameterException("Can not switch from a secure session to a non-secure session"); } return super.setParent(newParent); }