python - Routing os.exec* output to string -


i trying modify python's http.server.cgihttprequesthandler calculate content-length cgi scripts. below code /lib/http/server.py child process spawned. want capture output string can calculate size of in bytes, , send wfile, not sure how route output string instead of file descriptor.

# child try:     try:         os.setuid(nobody)     except os.error:         pass     os.dup2(self.rfile.fileno(), 0)     os.dup2(self.wfile.fileno(), 1)     os.execve(scriptfile, args, env) except:     self.server.handle_error(self.request, self.client_address)     os._exit(127) 

(line 1129 - 1140 of http://hg.python.org/cpython/file/3.3/lib/http/server.py)

perhaps incorrect way go calculating content-length send me suggested alternatives.

the code need (aside setting content-length header) in else branch of if self.have_fork. use case, seems want use subprocesses , rid of if self.have_fork part of code.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -