use of io.netty.handler.codec.http.HttpMethod in project flink by apache.
the class Router method allowedMethods.
/**
* Returns allowed methods for a specific URI.
*
* <p>For {@code OPTIONS *}, use {@link #allAllowedMethods()} instead of this method.
*/
public Set<HttpMethod> allowedMethods(String uri) {
QueryStringDecoder decoder = new QueryStringDecoder(uri);
String[] tokens = PathPattern.removeSlashesAtBothEnds(decoder.path()).split("/");
if (anyMethodRouter.anyMatched(tokens)) {
return allAllowedMethods();
}
Set<HttpMethod> ret = new HashSet<HttpMethod>(routers.size());
for (Map.Entry<HttpMethod, MethodlessRouter<T>> entry : routers.entrySet()) {
MethodlessRouter<T> router = entry.getValue();
if (router.anyMatched(tokens)) {
HttpMethod method = entry.getKey();
ret.add(method);
}
}
return ret;
}
use of io.netty.handler.codec.http.HttpMethod in project flink by apache.
the class RouterHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, HttpRequest httpRequest) {
if (HttpHeaders.is100ContinueExpected(httpRequest)) {
channelHandlerContext.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE));
return;
}
// Route
HttpMethod method = httpRequest.getMethod();
QueryStringDecoder qsd = new QueryStringDecoder(httpRequest.uri());
RouteResult<?> routeResult = router.route(method, qsd.path(), qsd.parameters());
if (routeResult == null) {
respondNotFound(channelHandlerContext, httpRequest);
return;
}
routed(channelHandlerContext, routeResult, httpRequest);
}
use of io.netty.handler.codec.http.HttpMethod in project crate by crate.
the class HttpBlobHandler method possibleRedirect.
private boolean possibleRedirect(HttpRequest request, String index, String digest) {
HttpMethod method = request.method();
if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.HEAD) || (method.equals(HttpMethod.PUT) && HttpUtil.is100ContinueExpected(request))) {
String redirectAddress;
try {
redirectAddress = blobService.getRedirectAddress(index, digest);
} catch (MissingHTTPEndpointException ex) {
simpleResponse(request, HttpResponseStatus.BAD_GATEWAY);
return true;
}
if (redirectAddress != null) {
LOGGER.trace("redirectAddress: {}", redirectAddress);
sendRedirect(request, activeScheme + redirectAddress);
return true;
}
}
return false;
}
Aggregations