47 questions
-2
votes
0
answers
74
views
How can http.Server be made to hold open a connection? [closed]
I'd like to add a unit test for Go's http.Server.Shutdown() timing out, but there are no connections held open when the shutdown signal is sent, so it never gets to checking for timeouts, even though ...
0
votes
0
answers
54
views
Python http.server requests gets reset (RST) connection after every request using curl when trying to run HTTPS server
With Curl I get the data correcty, but after connection:
command:
curl https://172.17.0.1:8443
Result:
<html>
<data>....</data>
...
curl: (56) OpenSSL SSL_read: error:0A000126:SSL ...
0
votes
1
answer
132
views
Is it safe to use multiple listeners (HTTP and HTTPS) for a server with the default ServeMux in Go?
I'm trying to set up an HTTP and HTTPS server on a Go application using http.server with default http.ServeMux. Specifically, I want one listener to handle HTTP traffic and the other to handle HTTPS ...
1
vote
1
answer
79
views
Why does the BaseHTTPRequestHandler rfile.read() delay execution?
I am making a simple server in python using http.server package. My goal is to log the data of POST from client to server. The problem I am having is rfile.read() is delaying execution until next POST ...
2
votes
1
answer
3k
views
python -m http.server gives "Serving HTTP on :: port 8000 (http://[::]:8000/) ..." Vs "Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..."
I'm very inexpert at this but when I use on different projects:
python -m http.server
a project answers with:
Serving HTTP on :: port 8000 (http://[::]:8000/) ...
the other with:
Serving HTTP on 0.0....
-1
votes
1
answer
107
views
How to forward requests made to docker container to http.server running inside the container using compose or Dockerfile configuration?
I have the following python code to create a server. The prints are triggered when the server is run up outside a docker container but not when inside a container. I'd like to setup port forwarding ...
1
vote
1
answer
2k
views
how can I force specific mime types for python's http.server?
I have a bunch of files without extensions, so http.server is serving them all as application/octet-stream and this is causing problems...
Rather than giving them extensions, I would like a way to ...
0
votes
1
answer
90
views
Why http.server does not deliver the data to the CGI script in this basic example?
I am testing the legacy CGI functionality of python http.server module by implementing a "hello world" alike example that sends data from a fictional "add customer" form from the ...
0
votes
1
answer
60
views
Python http server REMOTE_ADDR returns another local ip (Linux)
(I use Linux)
The local IP of my PC is 172.16.1.2
ip a command returns 172.16.1.2
Then I can add another IP to the same network interface:
ip addr add 192.168.1.10 dev eth0
now ip a command returns 2 ...
1
vote
2
answers
140
views
How to output multiline string returned by function with `http.server`?
So I have a basic http server running and for the most part it does what I want, but I want to improve on it.
I am brand new to http.server and quite new to Python still.
I have been able to print my ...
0
votes
0
answers
749
views
Python: http.server.ThreadingHTTPServer fails since update to Python 3.12
I've got a simple Python HTTP server application based on http.server.ThreadingHTTPServer, running in a Docker container. It works fine with Python 3.11, but under Python 3.12 aborts with the ...
1
vote
1
answer
389
views
in python threadinghttpserver - stop server from inside handler
I have the following "main" code:
with http.server.ThreadingHTTPServer( ("", port), Handler ) as daemon:
print(f"serving on port {port} process {os.getpid()} ")
...
1
vote
1
answer
73
views
multiprocessing Queue randomly skips items when used with forked http.server
I'm not very experienced with multiprocessing but today I tried making a small http+api server when I noticed I have to press the login button multiple times to get into my account, I tried to ...
2
votes
1
answer
1k
views
Python http.server and BaseHTTPRequestHandler - Multi-endpoint API
By doing python -m http.server you can invoke a simple web server which serves files in a directory.
My question is how I can use this to make multiple API endpoints with BaseHTTPRequestHandler
E.g. ...
1
vote
1
answer
496
views
How do I get the body of a PUT request in SimpleHTTPRequestHandler
I have this super simple HTTP server to test some REST endpoints:
import http.server
class MyHandler(http.server.SimpleHTTPRequestHandler):
def do_PUT(self):
self.send_response(200)
...