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


Java HttpServerRequest.getUri方法代码示例

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


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

示例1: simulateTimeout

import io.reactivex.netty.protocol.http.server.HttpServerRequest; //导入方法依赖的package包/类
public Observable<Void> simulateTimeout(HttpServerRequest<ByteBuf> httpRequest, HttpServerResponse<ByteBuf> response) {
    String uri = httpRequest.getUri();
    QueryStringDecoder decoder = new QueryStringDecoder(uri);
    List<String> timeout = decoder.parameters().get("timeout");
    byte[] contentBytes;
    HttpResponseStatus status = HttpResponseStatus.NO_CONTENT;
    if (null != timeout && !timeout.isEmpty()) {
        try {
            Thread.sleep(Integer.parseInt(timeout.get(0)));
            contentBytes = "".getBytes();
        } catch (Exception e) {
            contentBytes = e.getMessage().getBytes();
            status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
        }
    } else {
        status = HttpResponseStatus.BAD_REQUEST;
        contentBytes = "Please provide a timeout parameter.".getBytes();
    }

    response.setStatus(status);
    return response.writeBytesAndFlush(contentBytes);
}
 
开发者ID:allenxwang,项目名称:RxNetty,代码行数:23,代码来源:RequestProcessor.java

示例2: handle

import io.reactivex.netty.protocol.http.server.HttpServerRequest; //导入方法依赖的package包/类
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
    String uri = request.getUri();
    if (uri.startsWith("test/singleEntity")) {
        return handleSingleEntity(response);
    } else if (uri.startsWith("test/stream")) {
        return handleStream(response);
    } else if (uri.startsWith("test/nochunk_stream")) {
        return handleStreamWithoutChunking(response);
    } else if (uri.startsWith("test/largeStream")) {
        return handleLargeStream(response);
    } else if (uri.startsWith("test/timeout")) {
        return simulateTimeout(request, response);
    } else if (uri.startsWith("test/post")) {
        return handlePost(request, response);
    } else {
        response.setStatus(HttpResponseStatus.NOT_FOUND);
        return response.flush();
    }
}
 
开发者ID:allenxwang,项目名称:RxNetty,代码行数:21,代码来源:RequestProcessor.java

示例3: getRequestUriPath

import io.reactivex.netty.protocol.http.server.HttpServerRequest; //导入方法依赖的package包/类
/**
 * Parses (if not done previously) and returns the path component in the URI.
 *
 * @param httpRequest HTTP request for which the URI path is to be returned.
 *
 * @return The path component of the URI (as returned by {@link HttpRequest#getUri()} or {@code null} if the
 * URI is null.
 */
String getRequestUriPath(HttpServerRequest<?> httpRequest) {
    String uri = httpRequest.getUri();
    if (null == uri) {
        return null;
    }

    if (null == queryStringDecoder) {
        if (null == channel) {
            queryStringDecoder = new QueryStringDecoder(uri);
        } else {
            queryStringDecoder = getOrCreateQueryStringDecoder(httpRequest);
        }
    }

    return queryStringDecoder.nettyDecoder().path();
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:25,代码来源:HttpKeyEvaluationContext.java

示例4: getOrCreateQueryStringDecoder

import io.reactivex.netty.protocol.http.server.HttpServerRequest; //导入方法依赖的package包/类
private QueryStringDecoder getOrCreateQueryStringDecoder(HttpServerRequest<?> request) {
    if (null == request) {
        throw new NullPointerException("Request can not be null.");
    }
    String uri = request.getUri();
    if (null == uri) {
        return null;
    }

    Attribute<QueryStringDecoder> queryDecoderAttr = channel.attr(queryDecoderKey);

    QueryStringDecoder _queryStringDecoder = queryDecoderAttr.get();

    if (null == _queryStringDecoder) {
        _queryStringDecoder = new QueryStringDecoder(uri);
        queryDecoderAttr.setIfAbsent(_queryStringDecoder);
    }
    return _queryStringDecoder;
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:20,代码来源:HttpKeyEvaluationContext.java

示例5: bridgeRequest

import io.reactivex.netty.protocol.http.server.HttpServerRequest; //导入方法依赖的package包/类
ContainerRequest bridgeRequest(final HttpServerRequest<ByteBuf> nettyRequest, InputStream requestData ) {
    try {
        URI baseUri = new URI("/"); // Since the netty server does not have a context path element as such, so base uri is always /
        URI uri = new URI(nettyRequest.getUri());
        return new ContainerRequest(application, nettyRequest.getHttpMethod().name(),
                                    baseUri, uri, new JerseyRequestHeadersAdapter(nettyRequest.getHeaders()),
                                    requestData );
    } catch (URISyntaxException e) {
        logger.error(String.format("Invalid request uri: %s", nettyRequest.getUri()), e);
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:13,代码来源:NettyToJerseyBridge.java


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