Disconnect the server after sending http reponse

I am using Django in an IoT application.
The web client is a controller that is connecting to the computer using an ethernet cable.
I am using Django to listen for incoming POST requests, but the controller is behaving in an insanely manner because it expects the server to disconnect after sending the response to it.
The controller is also sending an http header “Connection: close”
which is not permitted in Django in the first place as it is a hop-by-hop header.

What can I do to make Django disconnect the client after sending the response?

Should I switch to pure code approach instead of using a web framework to achieve the task?

I’m assuming that by “disconnect”, you’re referring to closing the TCP socket that was opened to issue the HTTP request. (If you’re referring to something else, please clarify.)

If this is truly a situation where you want to issue one HTTP request and receive one response, then you would want to issue the request as an HTTP/1.0 request. (That’s assuming that the web server you’re using in front of Django is configured to support HTTP/1.0 and that the other semantics of HTTP/1.0 are sufficient for your application.)

If you still need to use HTTP/1.1, then you want to look at how the server is configured for keeping that socket. For example, nginx has the “keepalive” settings that could be used to manage this. (See Module ngx_http_core_module).
Note: if you use this, you’d want to set up a separate port for your controller to access. You do not want this set for general users.)

If that doesn’t work, then it’s up to the client to close the TCP socket.

The problem was caused by something else.
I appreciate your assistance.
I have submitted an additional question regarding the actual root cause, having verified that I found the root cause from the controller log files.”

This is the link to the additional question if anyone is interested in following through:
“Content-Length” Header in Django Framework for IoT Application