millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Fixed issue where redirect checker was clobbering url #635

Closed noonker closed 4 years ago

noonker commented 4 years ago

I was experiencing an issue where I could not save files (not notebooks) on Jupiterhub servers. The problem was that on jupyterhub servers the url-or-port combo should look like https://jupyterhub.example.com:8000/home/user but for some reason the save function was clobbering the home/user part of the url yielding a http 405. I traced the issue down to the ein:content-query-contents--success function.

The logic here seems to be a bit wrong. If there is a response it calls ein:get-response-redirect it which has the conditional(if (length (request-response-history response)). I don't think this conditional will ever be false since request-response-history is a list according to the request.el documents and even if the length is 0 this evaluates to t.

I don't know how the redirected requests look so I didn't modify the ein:get-response-request code except to remove the superfluous conditional. I also added what I /think/ the correct logic should be to the code that calls this code. This involved removing the ein:aif macro. I'm not super familiar with this code so I don't know if that macro is important.

noonker commented 4 years ago

It might make more sense to modify ein:get-response-redirect to understand the jupyterhub hierarchy but I'm not sure of a clean way to do that.

millejoh commented 4 years ago

Good catch - thanks. Now all is needed is a test case to prove everything is okay, but no worries on that. I'll go ahead and merge this in - if you think of a way to test all this let me know or feel free to submit another PR.