andreif / uwsgi-tools

curl and proxy for remote uwsgi app server
BSD 3-Clause "New" or "Revised" License
43 stars 11 forks source link

Encode error when greping response #5

Closed mvidalgarcia closed 6 years ago

mvidalgarcia commented 6 years ago
$ uwsgi_curl 127.0.0.1:59999 | grep HTTP/1.1                                                                                                                       
Traceback (most recent call last):                                                                                                                                                                                        
  File "./opt/indico/.venv/bin/uwsgi_curl", line 11, in <module>                                                                                                                                                          
    sys.exit(cli())                                                                                                                                                                                                       
  File "/opt/indico/.venv/lib/python2.7/site-packages/uwsgi_tools/curl.py", line 97, in cli                                                                                                                               
    print(response)                                                                                                                                                                                                       
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 208: ordinal not in range(128) 

When I don't grep the response, it gets properly printed in the console but it fails when I try to grep it.

Is there a way to just get the HTTP status code?

andreif commented 6 years ago

Thanks for you report!

Do you need to get the status code only or it will be fine with how normal curl responds with -i/-I arg?

mvidalgarcia commented 6 years ago

I think an arg like -i/-I should be fine and more appropriate.

Edit: Btw, to do some tests I had to fork your repo and implemented an arg option to just get the status code. Let me know if you want a PR. (https://github.com/mvidalgarcia/uwsgi-tools/commit/18614aa57ccf8db3366d7a84cd6b36818fc213aa)