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


Java HttpServerExchange.getRequestPath方法代码示例

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


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

示例1: doAuthorize

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void doAuthorize(HttpServerExchange exchange) throws  ServerError{
	Map<String, Deque<String>> queryParams = exchange.getQueryParameters();
       Deque<String> parameter = queryParams.get("apiKey");
       String apiKey = parameter.getFirst();

       
	String path = exchange.getRequestPath();
	String threescaleMethod = getThreescaleMethodName(path);
	
	AuthorizeResponse auth = pluginService.authRep(apiKey, threescaleMethod);

	if (auth!=null && (!auth.success())){
		//TODO find non-deprecated way of doing this.
		exchange.setResponseCode(403);
   	}
}
 
开发者ID:tnscorcoran,项目名称:light-4-j-plugin-wrapper,代码行数:18,代码来源:PluginWrapperClient.java

示例2: CachedHttpRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public CachedHttpRequest(final HttpServerExchange exchange) {
    this.path = exchange.getRequestPath();
    this.etag = ETagUtils.getETag(exchange);
    this.contentLocation = exchange.getResponseHeaders().getFirst(Headers.CONTENT_LOCATION);
    this.language = exchange.getResponseHeaders().getFirst(Headers.CONTENT_LANGUAGE);
    this.contentType = exchange.getResponseHeaders().getFirst(Headers.CONTENT_TYPE);
    String lmString = exchange.getResponseHeaders().getFirst(Headers.LAST_MODIFIED);
    if (lmString == null) {
        this.lastModified = null;
    } else {
        this.lastModified = DateUtils.parseDate(lmString);
    }
    //the content encoding can be decided dynamically, based on the current state of the request
    //as the decision to compress generally depends on size and mime type
    final AllowedContentEncodings encoding = exchange.getAttachment(AllowedContentEncodings.ATTACHMENT_KEY);
    if(encoding != null) {
        this.contentEncoding = encoding.getCurrentContentEncoding();
    } else {
        this.contentEncoding = exchange.getResponseHeaders().getFirst(Headers.CONTENT_ENCODING);
    }
    this.responseCode = exchange.getResponseCode();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:CachedHttpRequest.java

示例3: trySaveRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public static void trySaveRequest(final HttpServerExchange exchange) {
    int maxSize = exchange.getConnection().getUndertowOptions().get(UndertowOptions.MAX_BUFFERED_REQUEST_SIZE, 16384);
    if (maxSize > 0) {
        //if this request has a body try and cache the response
        if (!exchange.isRequestComplete()) {
            final long requestContentLength = exchange.getRequestContentLength();
            if (requestContentLength > maxSize) {
                UndertowLogger.REQUEST_LOGGER.debugf("Request to %s was to large to save", exchange.getRequestURI());
                return;//failed to save the request, we just return
            }
            //TODO: we should really be used pooled buffers
            //TODO: we should probably limit the number of saved requests at any given time
            byte[] buffer = new byte[maxSize];
            int read = 0;
            int res = 0;
            InputStream in = exchange.getInputStream();
            try {
                while ((res = in.read(buffer, read, buffer.length - read)) > 0) {
                    read += res;
                    if (read == maxSize) {
                        UndertowLogger.REQUEST_LOGGER.debugf("Request to %s was to large to save", exchange.getRequestURI());
                        return;//failed to save the request, we just return
                    }
                }
                HeaderMap headers = new HeaderMap();
                for(HeaderValues entry : exchange.getRequestHeaders()) {
                    if(entry.getHeaderName().equals(Headers.CONTENT_LENGTH) ||
                            entry.getHeaderName().equals(Headers.TRANSFER_ENCODING) ||
                            entry.getHeaderName().equals(Headers.CONNECTION)) {
                        continue;
                    }
                    headers.putAll(entry.getHeaderName(), entry);
                }
                SavedRequest request = new SavedRequest(buffer, read, exchange.getRequestMethod(), exchange.getRequestPath(), exchange.getRequestHeaders());
                final ServletRequestContext sc = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
                HttpSessionImpl session = sc.getCurrentServletContext().getSession(exchange, true);
                Session underlyingSession;
                if(System.getSecurityManager() == null) {
                    underlyingSession = session.getSession();
                } else {
                    underlyingSession = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(session));
                }
                underlyingSession.setAttribute(SESSION_KEY, request);
            } catch (IOException e) {
                UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:SavedRequest.java


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