public NettyRequest(final ChannelHandlerContext ctx, final HttpRequest req, final HttpHeaders responseHeaders, final String tmpdir, final int wsMaxMessageSize) { this.ctx = ctx; this.req = req; this.responseHeaders = responseHeaders; this.tmpdir = tmpdir; this.query = new QueryStringDecoder(req.uri()); this.path = Router.decode(query.path()); this.wsMaxMessageSize = wsMaxMessageSize; Channel channel = ctx.channel(); channel.attr(ASYNC).set(false); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; Channel channel = ctx.channel(); QueryStringDecoder queryDecoder = new QueryStringDecoder(req.uri()); HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.BAD_REQUEST); ChannelFuture f = channel.writeAndFlush(res); f.addListener(ChannelFutureListener.CLOSE); req.release(); log.warn("Blocked wrong socket.io-context request! url: {}, params: {}, ip: {}", queryDecoder.path(), queryDecoder.parameters(), channel.remoteAddress()); return; } super.channelRead(ctx, msg); }
if (request != null) { QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri()); String path = queryStringDecoder.path(); String[] array = path.split("/"); if (array.length == 2) {
if (request != null) { QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri()); String path = queryStringDecoder.path(); String[] array = path.split("/"); if (array.length == 2) {
FullHttpRequest req = (FullHttpRequest) msg; QueryStringDecoder queryDecoder = new QueryStringDecoder(req.uri()); String path = queryDecoder.path(); List<String> transport = queryDecoder.parameters().get("transport"); List<String> sid = queryDecoder.parameters().get("sid");
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, ctx.channel()); disconnectScheduler.cancel(key); if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; Channel channel = ctx.channel(); QueryStringDecoder queryDecoder = new QueryStringDecoder(req.uri()); if (!configuration.isAllowCustomRequests() && !queryDecoder.path().startsWith(connectPath)) { HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.BAD_REQUEST); channel.writeAndFlush(res).addListener(ChannelFutureListener.CLOSE); req.release(); return; } List<String> sid = queryDecoder.parameters().get("sid"); if (queryDecoder.path().equals(connectPath) && sid == null) { String origin = req.headers().get(HttpHeaderNames.ORIGIN); if (!authorize(ctx, channel, origin, queryDecoder.parameters(), req)) { req.release(); return; } // forward message to polling or websocket handler to bind channel } } ctx.fireChannelRead(msg); }
public static HttpRequest newRequest(final FullHttpRequest request) { QueryStringDecoder decoder = new QueryStringDecoder(request.uri()); ImmutableMap<String, String[]> queries = toQueries(decoder); return builder() .withVersion(HttpProtocolVersion.versionOf(request.protocolVersion().text())) .withHeaders(toHeaders(request)) .withMethod(HttpMethod.valueOf(request.method().toString().toUpperCase())) .withUri(decoder.path()) .withQueries(queries) .withContent(toMessageContent(request)) .build(); }
private static String getPath(QueryStringDecoder decoder) throws FileNotFoundException { String path = decoder.path(); if (path.startsWith(WEBHDFS_PREFIX)) { return path.substring(WEBHDFS_PREFIX_LENGTH); } else { throw new FileNotFoundException("Path: " + path + " should " + "start with " + WEBHDFS_PREFIX); } } }
ParameterParser(QueryStringDecoder decoder, Configuration conf) { this.path = decoder.path().substring(WEBHDFS_PREFIX_LENGTH); this.params = decoder.parameters(); this.conf = conf; }
String [] segments = decoder.path().split(URI_PATH_SEPARATOR); StringBuilder builder = new StringBuilder();
public EnumSet<CreateFlag> createFlag() { String cf = ""; if (param(CreateFlagParam.NAME) != null) { QueryStringDecoder decoder = new QueryStringDecoder( param(CreateFlagParam.NAME), StandardCharsets.UTF_8); cf = decoder.path(); } return new CreateFlagParam(cf).getValue(); }
public static HttpRequestWithDecodedQueryParams create(FullHttpRequest request) { final QueryStringDecoder decoder = new QueryStringDecoder(request.getUri()); request.setUri(decoder.path()); return new HttpRequestWithDecodedQueryParams(request, decoder.parameters()); }
private static String getPath(QueryStringDecoder decoder) throws FileNotFoundException { String path = decoder.path(); if (path.startsWith(WEBHDFS_PREFIX)) { return path.substring(WEBHDFS_PREFIX_LENGTH); } else { throw new FileNotFoundException("Path: " + path + " should " + "start with " + WEBHDFS_PREFIX); } } }
ParameterParser(QueryStringDecoder decoder, Configuration conf) { this.path = decodeComponent(decoder.path().substring (WEBHDFS_PREFIX_LENGTH), Charsets.UTF_8); this.params = decoder.parameters(); this.conf = conf; }
public NettyRequest(final ChannelHandlerContext ctx, final HttpRequest req, final HttpHeaders responseHeaders, final String tmpdir, final int wsMaxMessageSize) { this.ctx = ctx; this.req = req; this.responseHeaders = responseHeaders; this.tmpdir = tmpdir; this.query = new QueryStringDecoder(req.uri()); this.path = Router.decode(query.path()); this.wsMaxMessageSize = wsMaxMessageSize; Channel channel = ctx.channel(); channel.attr(ASYNC).set(false); }
@Override public String getPath() { if (uri == null) { uri = new QueryStringDecoder(request.uri()); } return uri.path(); }
public String path() { if (qs == null) { qs = new QueryStringDecoder(request.getUri()); } return qs.path(); }
public Optional<ApiMacher> getOperationFor(HttpMethod method, QueryStringDecoder queryStringDecoder) { return operations.stream().filter(operation -> operation.method().equals(method)) .map(operation -> new ApiMacher(operation, operation.pathTemplate().matcher(queryStringDecoder.path()),queryStringDecoder.parameters())) .filter(operation -> operation.matcher().matches()) .findFirst(); }
/** * check Root Path * * @param uri * @param queryStringDecoder * @return */ public void checkRootPath(String uri, QueryStringDecoder queryStringDecoder) { if (!PathUtil.getRootPath(queryStringDecoder.path()).equals(this.getRootPath())) { throw new CicadaException(StatusEnum.REQUEST_ERROR, uri); } } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final FullHttpRequest request) throws Exception { final String path = new QueryStringDecoder(request.getUri()).path(); for (SockJsServiceFactory factory : factories.values()) { if (path.startsWith(factory.config().prefix())) { handleService(factory, request, ctx); return; } } writeNotFoundResponse(request, ctx); }