Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request.lua:67: attempt to index local 'ctype' #17

Open
christopher5106 opened this issue Sep 4, 2016 · 2 comments
Open

request.lua:67: attempt to index local 'ctype' #17

christopher5106 opened this issue Sep 4, 2016 · 2 comments

Comments

@christopher5106
Copy link
Contributor

I got this kind of error during a POST

Request from POST/api/v1/
/root/torch/install/bin/luajit: /root/torch/install/share/lua/5.1/waffle/request.lua:67: attempt to index local 'ctype' (a nil value)
stack traceback:
/root/torch/install/share/lua/5.1/waffle/request.lua:67: in function '_getform'
/root/torch/install/share/lua/5.1/waffle/request.lua:140: in function 'Request'
/root/torch/install/share/lua/5.1/waffle/app.lua:93: in function 'handler'
/root/torch/install/share/lua/5.1/async/http.lua:161: in function </root/torch/install/share/lua/5.1/async/http.lua:110>
[C]: in function 'execute'
/root/torch/install/share/lua/5.1/async/http.lua:224: in function 'cb'
/root/torch/install/share/lua/5.1/async/handle.lua:33: in function </root/torch/install/share/lua/5.1/async/handle.lua:32>
[C]: in function 'run'
/root/torch/install/share/lua/5.1/async/init.lua:35: in function 'go'
/root/torch/install/share/lua/5.1/waffle/app.lua:143: in function 'listen'
api/init.lua:88: in main chunk
[C]: in function 'dofile'
/root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670

Thanks a lot for your help

@christopher5106
Copy link
Contributor Author

The errors comes with Python post :

r = requests.post(url, data=param, files={'file': open(img_path, 'rb')})

It works with cURL:

curl URL -F "file=@test/test_imgs/sushi.jpg" -F "model=default"

@christopher5106
Copy link
Contributor Author

I verified. Indeed, with python-requests, there is no content-type header.
Cf http://docs.python-requests.org/en/master/user/quickstart/, section Post a multipart-encoded file.
To have the content type, it is optional with the following syntax :

url = 'http://httpbin.org/post'
files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}
r = requests.post(url, files=files)

So it might be good to have the server work without content type header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant