当前位置: 首页>>代码示例>>Java>>正文


Java FullHttpRequest.uri方法代码示例

本文整理汇总了Java中io.netty.handler.codec.http.FullHttpRequest.uri方法的典型用法代码示例。如果您正苦于以下问题:Java FullHttpRequest.uri方法的具体用法?Java FullHttpRequest.uri怎么用?Java FullHttpRequest.uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.codec.http.FullHttpRequest的用法示例。


在下文中一共展示了FullHttpRequest.uri方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doDispatcher

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
/**
 * 请求分发与处理
 *
 * @param request http协议请求
 * @return 处理结果
 * @throws InvocationTargetException 调用异常
 * @throws IllegalAccessException    参数异常
 */
public Object doDispatcher(FullHttpRequest request) throws InvocationTargetException, IllegalAccessException {
    Object[] args;
    String uri = request.uri();
    if (uri.endsWith("favicon.ico")) {
        return "";
    }

    AceServiceBean aceServiceBean = Context.getAceServiceBean(uri);
    AceHttpMethod aceHttpMethod = AceHttpMethod.getAceHttpMethod(request.method().toString());
    ByteBuf content = request.content();
    //如果要多次解析,请用 request.content().copy()
    QueryStringDecoder decoder = new QueryStringDecoder(uri);
    Map<String, List<String>> requestMap = decoder.parameters();
    Object result = aceServiceBean.exec(uri, aceHttpMethod, requestMap, content == null ? null : content.toString(CharsetUtil.UTF_8));
    String contentType = request.headers().get("Content-Type");
    if (result == null) {
        ApplicationInfo mock = new ApplicationInfo();
        mock.setName("ace");
        mock.setVersion("1.0");
        mock.setDesc(" mock  !!! ");
        result = mock;
    }
    return result;

}
 
开发者ID:ChenXun1989,项目名称:ace,代码行数:34,代码来源:DefaultDispatcher.java

示例2: handleRequest

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
/**
 * Processes an HTTP request
 * @param ctx The channel handler context
 * @param req The HTTP request
 */
public void handleRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) {
	log.warn("HTTP Request: {}", req);
       if (req.method() != GET) {
           sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
           return;
       }
       String uri = req.uri();
       if(!"/ws".equals(uri)) {
       	//channelRead(ctx, req);
       	final WebSocketServerProtocolHandler wsProto = ctx.pipeline().get(WebSocketServerProtocolHandler.class);
       	if(wsProto != null) {
       		try {
				wsProto.acceptInboundMessage(req);
				return;
			} catch (Exception ex) {
				log.error("Failed to dispatch http request to WebSocketServerProtocolHandler on channel [{}]", ctx.channel(), ex);
			}
       	}
       }
       log.error("Failed to handle HTTP Request [{}] on channel [{}]", req, ctx.channel());
       sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.MISDIRECTED_REQUEST));
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:28,代码来源:WebSocketServiceHandler.java

示例3: channelRead0

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
    QueryStringDecoder queryString = new QueryStringDecoder(request.uri());
    String streamId = streamId(request);
    int latency = toInt(firstValue(queryString, LATENCY_FIELD_NAME), 0);
    if (latency < MIN_LATENCY || latency > MAX_LATENCY) {
        sendBadRequest(ctx, streamId);
        return;
    }
    String x = firstValue(queryString, IMAGE_COORDINATE_X);
    String y = firstValue(queryString, IMAGE_COORDINATE_Y);
    if (x == null || y == null) {
        handlePage(ctx, streamId, latency, request);
    } else {
        handleImage(x, y, ctx, streamId, latency, request);
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:18,代码来源:Http2RequestHandler.java

示例4: Netty4HttpRequest

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
Netty4HttpRequest(NamedXContentRegistry xContentRegistry, FullHttpRequest request, Channel channel) {
    super(xContentRegistry, request.uri(), new HttpHeadersMap(request.headers()));
    this.request = request;
    this.channel = channel;
    if (request.content().isReadable()) {
        this.content = Netty4Utils.toBytesReference(request.content());
    } else {
        this.content = BytesArray.EMPTY;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Netty4HttpRequest.java

示例5: routeSetter

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
public static void routeSetter(Route route, FullHttpRequest fullHttpRequest) throws Exception {
    String path = fullHttpRequest.uri();
    HttpMethod method = fullHttpRequest.method();


    if (route.security()) {
        CheckResult checkResult = SecurityManager.check(route);
        if (!checkResult.isOk()) {
            throw checkResult.exception();
        }
    }

    //设置@PathVariable
    routePathVariableSetter(path, route);

    if (route.httpMethod().equals(HttpMethod.GET)) {
        //设置GET @RequestParam
        GETParamsSetter(path, route);
    } else if (route.httpMethod().equals(HttpMethod.POST)) {
        //设置POST @RequestParam
        POSTParamsSetter(fullHttpRequest, route);
    }

    //设置@RequestJson
    if ("application/json".equals(fullHttpRequest.headers().get("content-Type"))) {
        routeRequestJsonSetter(fullHttpRequest.content().copy().toString(CharsetUtil.UTF_8), route);
    }

    //设置@FILE
    if (fullHttpRequest.headers().get("content-Type") != null && fullHttpRequest.headers().get("content-Type").startsWith("multipart/form-data")) {
        fileSetter(fullHttpRequest, route);
    }

    //设置model
    modelSetter(fullHttpRequest, route);

}
 
开发者ID:zhyzhyzhy,项目名称:Ink,代码行数:38,代码来源:RouteSetter.java

示例6: createResponse

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
public FullHttpResponse createResponse(FullHttpRequest aRequest) {

    String uri = aRequest.uri();
    IHttpRequestListener listener = listeners.get(uri);
    if(listener == null) {
        String body = aRequest.content().toString(StandardCharsets.UTF_8);
        return error(uri, body, NOT_FOUND);
    }

    return listener.createResponse(aRequest);
}
 
开发者ID:evsinev,项目名称:docker-network-veth,代码行数:13,代码来源:DispatchHandler.java

示例7: handleWebSocket

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
/**
 * handle WebSocket request,then, the the RPC could happen in WebSocket.
 * 
 * @param ctx
 * @param request
 */
protected void handleWebSocket(final ChannelHandlerContext ctx, FullHttpRequest request) {
	if (logger.isDebugEnabled()) {
		logger.debug("handleWebSocket request: uri={}", request.uri());
	}
	// Handshake
	WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(request.uri(), null, true);
	WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(request);
	if (handshaker == null) {
		WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
		return;
	}
	ChannelFutureListener callback = websocketHandshakeListener(ctx, request);
	ChannelFuture future = handshaker.handshake(ctx.channel(), request);
	if (callback != null) {
		future.addListener(callback);
	}
	ChannelPipeline pipe = ctx.pipeline();
	if (pipe.get(WebsocketFrameHandler.class) == null) {
		pipe.addAfter(ctx.name(), "wsFrameHandler", new WebsocketFrameHandler(handshaker));
		ChannelHandler handlerAws = pipe.get(AwsProxyProtocolDecoder.class);
		if (handlerAws != null) {
			pipe.remove(handlerAws);
		}
		pipe.remove(ctx.name());// Remove current Handler
	}
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:33,代码来源:HttpThriftBufDecoder.java

示例8: channelRead0

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest httpRequest) throws Exception {
    DecoderResult result = httpRequest.decoderResult();
    if (!result.isSuccess()) {
        throw new BadRequestException(result.cause());
    }
    logger.info("Get search request: " + httpRequest.uri());

    // only decode get path is enough
    Map<String, List<String>> requestParameters;
    QueryStringDecoder stringDecoder = new QueryStringDecoder(httpRequest.uri());
    requestParameters = stringDecoder.parameters();

    QueryMeta meta = new QueryMeta();

    for(Map.Entry<String, List<String>> entry : requestParameters.entrySet()) {
        if (entry.getKey().equals("options[]")) {
            // add filters
            List<String> filters = entry.getValue();
            filters.forEach(filter -> {
                String[] typeVal = filter.split(":");
                meta.addMeta(typeVal[0], typeVal[1]);
            });
        } else if (entry.getKey().equals("orderby")) {
            meta.setOrderBy(entry.getValue().get(0));
        } else {
            logger.warn("Unknown query parameter, ignore it:" + entry.toString());
        }
    }

    DecodedSearchRequest searchRequest = new DecodedSearchRequest(httpRequest, meta, orderNumber++);
    ctx.fireChannelRead(searchRequest);
}
 
开发者ID:compasses,项目名称:elastic-rabbitmq,代码行数:34,代码来源:SearchQueryDecoder.java

示例9: HttpRequest

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
protected HttpRequest(FullHttpRequest fullHttpRequest) throws URISyntaxException {
	super(fullHttpRequest.protocolVersion(), fullHttpRequest.method(), fullHttpRequest.uri(),
			fullHttpRequest.content().copy());

	this.headers().set(fullHttpRequest.headers());
	this.trailingHeaders().set(fullHttpRequest.trailingHeaders());
	this.setDecoderResult(fullHttpRequest.decoderResult());
	this.uri = createUriWithNormalizing(fullHttpRequest.uri());

	this.parameters = parameters();
	this.cookies = cookies();
	this.pathParameters = Maps.newHashMap();
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:14,代码来源:HttpRequest.java

示例10: translate

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
public String translate(FullHttpRequest msg) {
    String data = msg.uri();
    int index = data.indexOf("?");
    if (index < 0) {
        return null;
    }
    String params = data.substring(index + 1, data.length());
    if (params.length() <= 0) {
        return null;
    }
    return data;
}
 
开发者ID:ogcs,项目名称:Okra-LOG,代码行数:14,代码来源:HttpProtocolHandler.java

示例11: RequestContext

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
public RequestContext(FullHttpRequest request, HttpCallback callback) {
    this.callback = callback;
    this.request = request;
    this.uri = request.uri();
    this.readTimeout = parseTimeout();
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:7,代码来源:RequestContext.java

示例12: decode

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest request, List<Object> out) throws Exception {
	// Handle a bad request.
	if (!request.decoderResult().isSuccess()) {
		sendHttpResponse(ctx, request, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
		return;
	}
	if ("websocket".equalsIgnoreCase((String) request.headers().get("Upgrade"))) {
		handleWebSocket(ctx, request);
		return;
	}

	String queryStr = request.uri();
	if ("/favicon.ico".equals(queryStr)) {
		FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, NOT_FOUND);
		sendHttpResponse(ctx, request, res);
		return;
	}
	if (queryStr != null) {
		queryStr = queryStr.trim();
		if (queryStr.length() > 0 && queryStr.charAt(0) == '/') {
			if (queryStr.length() == 1) {
				queryStr = "";
			} else {
				int wh = queryStr.indexOf('?');
				if (wh > 0) {
					queryStr = queryStr.substring(wh + 1);
				} else {
					queryStr = queryStr.substring(1);
				}
			}
		}
	} else {
		queryStr = "";
	}
	HttpMethod method = request.method();
	logger.debug("decode queryStr ={}, method={}, msg={}", queryStr, method, request);
	if (directHandleMethod(ctx, request, method)) {
		return;
	}
	ByteBuf content;
	if (queryStr.length() == 0) {
		if (HttpMethod.GET.equals(method)) {
			handleHttpHomePage(ctx, request);
			return;
		}
		content = request.content().retain();
	} else {
		queryStr = URLDecoder.decode(queryStr, "UTF-8");
		int strLen = queryStr.length();
		if (queryStr.charAt(0) != '[' && strLen > 5) {
			boolean wordOrLetter = Character.isLetterOrDigit(queryStr.charAt(strLen - 1));
			for (int i = 2, MAX = Math.min(strLen, 7); i < MAX; i++) {
				char c = queryStr.charAt(strLen - i);
				if (c == '.') {
					if (wordOrLetter) {
						serverDef.httpResourceHandler.process(ctx, request, queryStr, strLen - i);
						return;
					}
					break;
				} else if (wordOrLetter && !Character.isLetterOrDigit(c)) {
					wordOrLetter = false;
				}
			}
		}
		byte[] bytes = queryStr.getBytes();
		// System.err.println("URI: bytes[0] = "+bytes[0]+", len =
		// "+bytes.length);
		content = ctx.alloc().buffer(bytes.length);
		content.writeBytes(bytes);
	}
	logger.debug("content.size = " + content.readableBytes());
	out.add(content);
	boolean alive = HttpHeaderUtil.isKeepAlive(request);
	Object event = alive ? thriftMessageWrapperKeepAlive : thriftMessageWrapperNormal;
	ctx.fireUserEventTriggered(event);
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:78,代码来源:HttpThriftBufDecoder.java

示例13: isHandeled

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
protected boolean isHandeled(FullHttpRequest request) {
    String uri = request.uri();
    return uri.equals("/") || uri.equals("/values/path");
}
 
开发者ID:ganskef,项目名称:shortcircuit-proxy,代码行数:5,代码来源:EvaluationServerHomeHandler.java


注:本文中的io.netty.handler.codec.http.FullHttpRequest.uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。