本文整理汇总了Java中io.undertow.server.HttpServerExchange.setRelativePath方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.setRelativePath方法的具体用法?Java HttpServerExchange.setRelativePath怎么用?Java HttpServerExchange.setRelativePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.server.HttpServerExchange
的用法示例。
在下文中一共展示了HttpServerExchange.setRelativePath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeAttribute
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
int pos = newValue.indexOf('?');
if (pos == -1) {
exchange.setRelativePath(newValue);
exchange.setRequestURI(newValue);
exchange.setRequestPath(newValue);
exchange.setResolvedPath("");
} else {
final String path = newValue.substring(0, pos);
exchange.setRelativePath(path);
exchange.setRequestURI(path);
exchange.setRequestPath(path);
exchange.setResolvedPath("");
final String newQueryString = newValue.substring(pos);
exchange.setQueryString(newQueryString);
exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange)));
}
}
示例2: writeAttribute
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
int pos = newValue.indexOf('?');
if (pos == -1) {
exchange.setRelativePath(newValue);
exchange.setRequestURI(exchange.getResolvedPath() + newValue);
exchange.setRequestPath(exchange.getResolvedPath() + newValue);
} else {
final String path = newValue.substring(0, pos);
exchange.setRelativePath(path);
exchange.setRequestURI(exchange.getResolvedPath() + newValue);
exchange.setRequestPath(exchange.getResolvedPath() + newValue);
final String newQueryString = newValue.substring(pos);
exchange.setQueryString(newQueryString);
exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange)));
}
}
示例3: beginPathParameters
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private void beginPathParameters(ParseState state, HttpServerExchange exchange, StringBuilder stringBuilder, int parseState, int canonicalPathStart, boolean urlDecodeRequired) {
final String path = stringBuilder.toString();
if (parseState < HOST_DONE) {
String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash);
exchange.setRequestPath(decodedPath);
exchange.setRelativePath(decodedPath);
exchange.setRequestURI(path);
} else {
String thePath = path.substring(canonicalPathStart);
exchange.setRequestPath(thePath);
exchange.setRelativePath(thePath);
exchange.setRequestURI(path, true);
}
state.state = ParseState.PATH_PARAMETERS;
state.stringBuilder.setLength(0);
state.parseState = 0;
state.pos = 0;
state.urlDecodeRequired = false;
}
示例4: beginQueryParameters
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private void beginQueryParameters(ByteBuffer buffer, ParseState state, HttpServerExchange exchange, StringBuilder stringBuilder, int parseState, int canonicalPathStart, boolean urlDecodeRequired) {
final String path = stringBuilder.toString();
if (parseState < HOST_DONE) {
String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash);
exchange.setRequestPath(decodedPath);
exchange.setRelativePath(decodedPath);
exchange.setRequestURI(path, false);
} else {
handleFullUrl(state, exchange, canonicalPathStart, urlDecodeRequired, path);
}
state.state = ParseState.QUERY_PARAMETERS;
state.stringBuilder.setLength(0);
state.parseState = 0;
state.pos = 0;
state.urlDecodeRequired = false;
handleQueryParameters(buffer, state, exchange);
}
示例5: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
boolean handlingRequired = File.separatorChar != '/';
if (handlingRequired) {
exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/')));
exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/')));
exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/')));
}
next.handleRequest(exchange);
}
示例6: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
boolean decodeDone = exchange.getConnection().getUndertowOptions().get(UndertowOptions.DECODE_URL, true);
if (!decodeDone) {
final StringBuilder sb = new StringBuilder();
final boolean decodeSlash = exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALLOW_ENCODED_SLASH, false);
exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, sb));
exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, sb));
exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, sb));
if (!exchange.getQueryString().isEmpty()) {
final TreeMap<String, Deque<String>> newParams = new TreeMap<>();
for (Map.Entry<String, Deque<String>> param : exchange.getQueryParameters().entrySet()) {
final Deque<String> newVales = new ArrayDeque<>(param.getValue().size());
for (String val : param.getValue()) {
newVales.add(URLUtils.decode(val, charset, true, sb));
}
newParams.put(URLUtils.decode(param.getKey(), charset, true, sb), newVales);
}
exchange.getQueryParameters().clear();
exchange.getQueryParameters().putAll(newParams);
}
}
next.handleRequest(exchange);
}
示例7: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
final PathMatcher.PathMatch<HttpHandler> match = pathMatcher.match(exchange.getRelativePath());
if (match.getValue() == null) {
ResponseCodeHandler.HANDLE_404.handleRequest(exchange);
return;
}
exchange.setRelativePath(match.getRemaining());
exchange.setResolvedPath(exchange.getRequestPath().substring(0, exchange.getRequestPath().length() - match.getRemaining().length()));
match.getValue().handleRequest(exchange);
}
示例8: dispatchMockRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void dispatchMockRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException {
final ByteBufferSlicePool bufferPool = new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 1024, 1024);
MockServerConnection connection = new MockServerConnection(bufferPool);
HttpServerExchange exchange = new HttpServerExchange(connection);
exchange.setRequestScheme(request.getScheme());
exchange.setRequestMethod(new HttpString(request.getMethod()));
exchange.setProtocol(Protocols.HTTP_1_0);
exchange.setResolvedPath(request.getContextPath());
String relative;
if (request.getPathInfo() == null) {
relative = request.getServletPath();
} else {
relative = request.getServletPath() + request.getPathInfo();
}
exchange.setRelativePath(relative);
final ServletPathMatch info = paths.getServletHandlerByPath(request.getServletPath());
final HttpServletResponseImpl oResponse = new HttpServletResponseImpl(exchange, servletContext);
final HttpServletRequestImpl oRequest = new HttpServletRequestImpl(exchange, servletContext);
final ServletRequestContext servletRequestContext = new ServletRequestContext(servletContext.getDeployment(), oRequest, oResponse, info);
servletRequestContext.setServletRequest(request);
servletRequestContext.setServletResponse(response);
//set the max request size if applicable
if (info.getServletChain().getManagedServlet().getMaxRequestSize() > 0) {
exchange.setMaxEntitySize(info.getServletChain().getManagedServlet().getMaxRequestSize());
}
exchange.putAttachment(ServletRequestContext.ATTACHMENT_KEY, servletRequestContext);
exchange.startBlocking(new ServletBlockingHttpExchange(exchange));
servletRequestContext.setServletPathMatch(info);
try {
dispatchRequest(exchange, servletRequestContext, info.getServletChain(), DispatcherType.REQUEST);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new ServletException(e);
}
}
示例9: handlePath
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
* Parses a path value
*
* @param buffer The buffer
* @param state The current state
* @param exchange The exchange builder
* @return The number of bytes remaining
*/
@SuppressWarnings("unused")
final void handlePath(ByteBuffer buffer, ParseState state, HttpServerExchange exchange) {
StringBuilder stringBuilder = state.stringBuilder;
int parseState = state.parseState;
int canonicalPathStart = state.pos;
boolean urlDecodeRequired = state.urlDecodeRequired;
while (buffer.hasRemaining()) {
char next = (char) (buffer.get() & 0xFF);
if (next == ' ' || next == '\t') {
if (stringBuilder.length() != 0) {
final String path = stringBuilder.toString();
if (parseState < HOST_DONE) {
String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash);
exchange.setRequestPath(decodedPath);
exchange.setRelativePath(decodedPath);
exchange.setRequestURI(path);
} else {
handleFullUrl(state, exchange, canonicalPathStart, urlDecodeRequired, path);
}
exchange.setQueryString("");
state.state = ParseState.VERSION;
state.stringBuilder.setLength(0);
state.parseState = 0;
state.pos = 0;
state.urlDecodeRequired = false;
return;
}
} else if (next == '\r' || next == '\n') {
throw UndertowMessages.MESSAGES.failedToParsePath();
} else if (next == '?' && (parseState == START || parseState == HOST_DONE || parseState == IN_PATH)) {
beginQueryParameters(buffer, state, exchange, stringBuilder, parseState, canonicalPathStart, urlDecodeRequired);
return;
} else if (next == ';' && (parseState == START || parseState == HOST_DONE || parseState == IN_PATH)) {
beginPathParameters(state, exchange, stringBuilder, parseState, canonicalPathStart, urlDecodeRequired);
handlePathParameters(buffer, state, exchange);
return;
} else {
if (decode && (next == '+' || next == '%' || next > 127)) {
urlDecodeRequired = true;
} else if (next == ':' && parseState == START) {
parseState = FIRST_COLON;
} else if (next == '/' && parseState == FIRST_COLON) {
parseState = FIRST_SLASH;
} else if (next == '/' && parseState == FIRST_SLASH) {
parseState = SECOND_SLASH;
} else if (next == '/' && parseState == SECOND_SLASH) {
parseState = HOST_DONE;
canonicalPathStart = stringBuilder.length();
} else if (parseState == FIRST_COLON || parseState == FIRST_SLASH) {
parseState = IN_PATH;
} else if (next == '/' && parseState != HOST_DONE) {
parseState = IN_PATH;
}
stringBuilder.append(next);
}
}
state.parseState = parseState;
state.pos = canonicalPathStart;
state.urlDecodeRequired = urlDecodeRequired;
}
示例10: handleFullUrl
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private void handleFullUrl(ParseState state, HttpServerExchange exchange, int canonicalPathStart, boolean urlDecodeRequired, String path) {
String thePath = decode(path.substring(canonicalPathStart), urlDecodeRequired, state, allowEncodedSlash);
exchange.setRequestPath(thePath);
exchange.setRelativePath(thePath);
exchange.setRequestURI(path, true);
}
示例11: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.setRelativePath(CanonicalPathUtils.canonicalize(exchange.getRelativePath()));
next.handleRequest(exchange);
}