use of org.eclipse.jetty.http.pathmap.PathSpec in project jetty.project by eclipse.
the class NativeWebSocketConfiguration method removeMapping.
@Override
public boolean removeMapping(String rawspec) {
PathSpec pathSpec = toPathSpec(rawspec);
boolean removed = false;
for (Iterator<MappedResource<WebSocketCreator>> iterator = mappings.iterator(); iterator.hasNext(); ) {
MappedResource<WebSocketCreator> mapping = iterator.next();
if (mapping.getPathSpec().equals(pathSpec)) {
iterator.remove();
removed = true;
}
}
return removed;
}
use of org.eclipse.jetty.http.pathmap.PathSpec in project jetty.project by eclipse.
the class WebSocketUpgradeHandlerWrapper method handle.
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (configuration.getFactory().isUpgradeRequest(request, response)) {
MappedResource<WebSocketCreator> resource = configuration.getMatch(target);
if (resource == null) {
// no match.
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No websocket endpoint matching path: " + target);
return;
}
WebSocketCreator creator = resource.getResource();
// Store PathSpec resource mapping as request attribute
request.setAttribute(PathSpec.class.getName(), resource);
// We have an upgrade request
if (configuration.getFactory().acceptWebSocket(creator, request, response)) {
// We have a socket instance created
return;
}
// due to incoming request constraints (controlled by WebSocketCreator)
if (response.isCommitted()) {
// not much we can do at this point.
return;
}
}
super.handle(target, baseRequest, request, response);
}
Aggregations