Search in sources :

Example 6 with PathSpec

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;
}
Also used : WebSocketCreator(org.eclipse.jetty.websocket.servlet.WebSocketCreator) RegexPathSpec(org.eclipse.jetty.http.pathmap.RegexPathSpec) ServletPathSpec(org.eclipse.jetty.http.pathmap.ServletPathSpec) UriTemplatePathSpec(org.eclipse.jetty.http.pathmap.UriTemplatePathSpec) PathSpec(org.eclipse.jetty.http.pathmap.PathSpec) MappedResource(org.eclipse.jetty.http.pathmap.MappedResource)

Example 7 with PathSpec

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);
}
Also used : WebSocketCreator(org.eclipse.jetty.websocket.servlet.WebSocketCreator) PathSpec(org.eclipse.jetty.http.pathmap.PathSpec)

Aggregations

PathSpec (org.eclipse.jetty.http.pathmap.PathSpec)7 ServletPathSpec (org.eclipse.jetty.http.pathmap.ServletPathSpec)4 UriTemplatePathSpec (org.eclipse.jetty.http.pathmap.UriTemplatePathSpec)4 RegexPathSpec (org.eclipse.jetty.http.pathmap.RegexPathSpec)3 WebSocketCreator (org.eclipse.jetty.websocket.servlet.WebSocketCreator)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DispatcherType (javax.servlet.DispatcherType)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Extension (javax.websocket.Extension)1 Parameter (javax.websocket.Extension.Parameter)1 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)1 MappedResource (org.eclipse.jetty.http.pathmap.MappedResource)1 UserIdentity (org.eclipse.jetty.server.UserIdentity)1 ExtensionConfig (org.eclipse.jetty.websocket.api.extensions.ExtensionConfig)1 JsrExtension (org.eclipse.jetty.websocket.jsr356.JsrExtension)1 EndpointInstance (org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance)1 WebSocketServletFactory (org.eclipse.jetty.websocket.servlet.WebSocketServletFactory)1