Server won't start without explicitly passing host
Opened this issue · 3 comments
alexdelorenzo commented
Cool project, it works well for my needs.
There's an issue if you want to use httpcompressionserver
as a drop-in replacement for Python's http.server
, though.
When using http.server
, you don't need to supply a host value via command-line invocation. It'll just bind to 0.0.0.0
:
$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Launching httpcompressionserver
without explicitly providing a host to bind to fails.
$ python3 -m httpcompressionserver
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/alex/.local/lib/python3.8/site-packages/httpcompressionserver.py", line 313, in <module>
test(HandlerClass=HTTPCompressionRequestHandler,
File "/usr/lib/python3.8/http/server.py", line 1246, in test
ServerClass.address_family, addr = _get_best_family(bind, port)
File "/usr/lib/python3.8/http/server.py", line 1229, in _get_best_family
infos = socket.getaddrinfo(
File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
This works just fine:
$ python3 -m httpcompressionserver --bind 0.0.0.0
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
This was run on a Linux host.
jxu commented
Can the PyPI version be updated?
PierreQuentel commented
Thanks for the reminder, I completely forgot to upload to PyPI. It's done now.
air commented
Just ran into this, still happening. Thanks for filing the issue and workaround @alexdelorenzo