public Http1TestServer(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException { super(ioReactorConfig); this.registry = new RequestHandlerRegistry<>(); this.sslContext = sslContext; }
public void register(final String uriPattern, final Supplier<AsyncServerExchangeHandler> supplier) { registry.register(null, uriPattern, supplier); }
public Http2MultiplexingRequester create() { final RequestHandlerRegistry<Supplier<AsyncPushConsumer>> registry = new RequestHandlerRegistry<>(uriPatternType); for (final HandlerEntry<Supplier<AsyncPushConsumer>> entry: pushConsumerList) { registry.register(entry.hostname, entry.uriPattern, entry.handler); } final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory( httpProcessor != null ? httpProcessor : Http2Processors.client(), new DefaultAsyncPushConsumerFactory(registry), h2Config != null ? h2Config : H2Config.DEFAULT, charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT, streamListener); return new Http2MultiplexingRequester( ioReactorConfig, new IOEventHandlerFactory() { @Override public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) { return new Http2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, strictALPNHandshake); } }, ioSessionDecorator, sessionListener, DefaultAddressResolver.INSTANCE, tlsStrategy != null ? tlsStrategy : new H2ClientTlsStrategy()); }
@Test public void testByRequestUriWithQuery() throws Exception { handlerRegistry.register(null, "/test*", "stuff"); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/test?test=a"), context)); Assert.assertNotEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/tes?test=a"), context)); }
@Override public T resolve(final HttpRequest request, final HttpContext context) throws MisdirectedRequestException { final URIAuthority authority = request.getAuthority(); final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null; final LookupRegistry<T> patternMatcher = getPatternMatcher(key); if (patternMatcher == null) { throw new MisdirectedRequestException("Not authoritative"); } String path = request.getPath(); final int i = path.indexOf('?'); if (i != -1) { path = path.substring(0, i); } return patternMatcher.lookup(path); }
break; final RequestHandlerRegistry<Supplier<AsyncPushConsumer>> registry = new RequestHandlerRegistry<>(uriPatternType); for (final HandlerEntry<Supplier<AsyncPushConsumer>> entry: pushConsumerList) { registry.register(entry.hostname, entry.uriPattern, entry.handler);
@Test public void testResolveByRequestUri() throws Exception { handlerRegistry.register(null, "/test*", "stuff"); Assert.assertNotEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/"), context)); Assert.assertNotEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/abc"), context)); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/test"), context)); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", "/testabc"), context)); }
@Override public T resolve(final HttpRequest request, final HttpContext context) throws MisdirectedRequestException { final URIAuthority authority = request.getAuthority(); final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null; final LookupRegistry<T> patternMatcher = getPatternMatcher(key); if (patternMatcher == null) { throw new MisdirectedRequestException("Not authoritative"); } String path = request.getPath(); final int i = path.indexOf('?'); if (i != -1) { path = path.substring(0, i); } return patternMatcher.lookup(path); }
public HttpServer create() { final RequestHandlerRegistry<HttpRequestHandler> handlerRegistry = new RequestHandlerRegistry<>( canonicalHostName != null ? canonicalHostName : InetAddressUtils.getCanonicalLocalHostName(), uriPatternType); for (final HandlerEntry<HttpRequestHandler> entry: handlerList) { handlerRegistry.register(entry.hostname, entry.uriPattern, entry.handler);
public void register(final String uriPattern, final Supplier<AsyncServerExchangeHandler> supplier) { registry.register(null, uriPattern, supplier); }
public Http2TestServer(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException { super(ioReactorConfig); this.sslContext = sslContext; this.registry = new RequestHandlerRegistry<>(); }
public HttpServer create() { final RequestHandlerRegistry<HttpRequestHandler> handlerRegistry = new RequestHandlerRegistry<>( canonicalHostName != null ? canonicalHostName : InetAddressUtils.getCanonicalLocalHostName(), uriPatternType); for (final HandlerEntry<HttpRequestHandler> entry: handlerList) { handlerRegistry.register(entry.hostname, entry.uriPattern, entry.handler);
public void register(final String uriPattern, final Supplier<AsyncServerExchangeHandler> supplier) { registry.register(null, uriPattern, supplier); }
public Http1TestServer(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException { super(ioReactorConfig); this.registry = new RequestHandlerRegistry<>(); this.sslContext = sslContext; }
@Test public void testResolveByHostnameAndRequestUri() throws Exception { handlerRegistry.register("myhost", "/test*", "stuff"); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", new HttpHost("myhost"), "/test"), context)); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", new HttpHost("MyHost"), "/testabc"), context)); }
public HttpAsyncServer create() { final RequestHandlerRegistry<Supplier<AsyncServerExchangeHandler>> registry = new RequestHandlerRegistry<>( canonicalHostName != null ? canonicalHostName : InetAddressUtils.getCanonicalLocalHostName(), uriPatternType); for (final HandlerEntry<Supplier<AsyncServerExchangeHandler>> entry: handlerList) { registry.register(entry.hostname, entry.uriPattern, entry.handler);
public void register(final String uriPattern, final Supplier<AsyncServerExchangeHandler> supplier) { registry.register(null, uriPattern, supplier); }
public Http2TestClient(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException { super(ioReactorConfig); this.sslContext = sslContext; this.registry = new RequestHandlerRegistry<>(); }
@Test public void testResolveByLocalhostAndRequestUri() throws Exception { handlerRegistry.register("myhost", "/test*", "stuff"); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", new HttpHost("localhost"), "/test"), context)); Assert.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest("GET", new HttpHost("LocalHost"), "/testabc"), context)); }