jupyter / tmpnb-redirector

Simple HTTP redirector for tmpnb nodes
BSD 3-Clause "New" or "Revised" License
12 stars 16 forks source link

Added route and handler to allow spawning from redirector #9

Closed captainsafia closed 9 years ago

captainsafia commented 9 years ago

This is a WIP PR for #4. I'll ping you on here @rgbkrk if I need any help.

captainsafia commented 9 years ago

So, whenever I curl on the /api/spawn endpoint, I get a HTTP 405: Method Not Allowed error despite the fact that I am sending using POST (curl -X POST http://127.0.0.1:9000/api/spawn). Not sure, why this is happening, complete stack-trace below.

Traceback (most recent call last):
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/web.py", line 1415, in _execute
    result = yield result
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "redirector.py", line 180, in post
    response = yield http_client.fetch(request)
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/Users/safia/anaconda3/lib/python3.4/site-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 405: Method Not Allowed

I'm a confused cat and a frustrated ferret at the moment. I've tried laying out the request sending code in different ways but I don't think that's the problem.

minrk commented 9 years ago

@captainsafia I think it might be the trailing slash. Does it work if you do /api/spawn/ instead? I opened jupyter/tmpnb#173 to make tmpnb behave the same way whether the slash is there or not.

The fact that the error is in tornado.httpclient.HTTPError shows (not super clearly) that the error is not in the request between curl and redirector, but in the second request from redirector to tmpnb. And it's the upstream tmpnb that has /api/spawn/ as the URL (with trailing slash).

captainsafia commented 9 years ago

@minrk — You are absolutely right! That's one pesky bug, but good to note in the future. Thanks!

I updated the code and it works now.

captainsafia commented 9 years ago

@rgbkrk — peep it!

rgbkrk commented 9 years ago

Looking good!

rgbkrk commented 9 years ago

In the next couple days I'll deploy this and see how thebe fairs with it.