tornado does unescape the path pattern in PathMatches: https://www.tornadoweb.org/en/stable/_modules/tornado/routing.html#PathMatches
I ended encoding in base64 the path on the client side and decoding it in the server extension using urlsafe_b64decode <https://docs.python.org/3/library/base64.html#base64.urlsafe_b64decode> Le jeudi 6 décembre 2018 22:52:24 UTC+1, Benjamin Bertrand a écrit : > > Hi, > > I'm trying to create a JupyterLab extension to access GitLab based on > https://github.com/jupyterlab/jupyterlab-github > I'm having issues with the serverextension that acts as a proxy. > > In GitLab, the namespaced path > <https://docs.gitlab.com/ee/api/#namespaced-path-encoding> shall be > URL-encoded: user/repository shall be encoded as *user%2Frepository* > GET /api/v4/projects/diaspora%2Fdiaspora > > When I call* proxiedApiRequest<any>(requestUrl, this._serverSettings) *with > requestUrl set to > http://localhost:8888/gitlab/projects/gitlab-org%2Fci-training-sample/repository/tree? > in > javascript, on Python side, my handler gets the path > */projects/gitlab-org/ci-training-sample/repository/tree > *which of course results in a 404. > I'd expect to get* > /projects/gitlab-org%2Fci-training-sample/repository/tree* instead. > > get: /projects/gitlab-org/ci-training-sample/repository/tree > [W 22:23:42.676 LabApp] 404 GET /gitlab/projects/gitlab-org%2Fci-training- > sample/repository/tree?&1544131422149 (::1) 524.77ms referer=http: > //localhost:8888/lab > > > Is tornado automatically unescaping the endpoint? Is there a way around > that? > > > The Python code is almost the same as for the jupyterlab_github extension. > Any endpoint shall be passed to the handler: > > class GitLabHandler(APIHandler): > > @gen.coroutine > def get(self, path): > """ > Proxy API requests to GitLab, adding authentication parameter(s) if > they have been set. > """ > print(f"get: {path}") > ... > > > def load_jupyter_server_extension(nb_server_app): > web_app = nb_server_app.web_app > base_url = web_app.settings["base_url"] > endpoint = url_path_join(base_url, "gitlab") > handlers = [(endpoint + "(.*)", GitLabHandler)] > web_app.add_handlers(".*$", handlers) > > > -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/2225c3d7-41ce-461e-adb2-b5002bd9a0ab%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
