python - Nginx stream headers -


I have a simple HTTP server and I want to send some headers before the client, because the generation of content is really long Time (more than N seconds)

For example:

  HTTP 200 OK header- & gt; Some custom headers- & gt; Some lengthy operation - & gt; Content-length- & gt; \ N \ n- & gt; If there is no response to the server, some client devices are shutting down after 5 or more seconds. The source code contains an object "wfile" (socket descriptor, a file such as a file) ) Wfile.flush () sends the content to the customer in the standstate case all works fine The HTTP connection works on the nginx server and is waiting for the full response from the NJNEX backend. Is there a way to "flush" backend outout data? Config:  
  space / {# proxy_set_header X-real-IP $ remote_addr; #sendfile_max_chunk 0; Proxy_buffering off; Send file off; Proxy_pass srv; } # Server_tokens off; } 

  & lt ;! - Language: lang-python - & gt; SocketServer Import From ThreadingMixIn, TCPServer SimpleHTTPServer Import SimpleHTTPRequestHandler class from MyHandler (SimpleHTTPRequestHandler): Def do_Get (self): self.wfile.write ("Here are some headers \ n") self.wfile.flush () # --- Here are some long Blocking Operation Content = Blocking Operation () # Content-Length Header Generation ... Class Simple SRV (ThreadingMixine, TCPAserver): allow_reuse_address = True .... httpd = SimpleSrv (IP, port), Myhindler) httpd.serve_forever () < / Pre>  

nginx buffers response by default Longer reaction, you either "X-Excel buffering" header sent to this behavior can disable config option or backend by nginx.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -