[MERGE] xmlrpc,netrpc: try to minimize number of network packets sent for each RPC call

bzr revid: odo@openerp.com-20110118155743-uq0llrmz1zn9fr3p
This commit is contained in:
P.Christeas
2011-01-18 16:57:43 +01:00
committed by Olivier Dony
3 changed files with 10 additions and 11 deletions
+2
View File
@@ -123,10 +123,12 @@ class HttpLogHandler:
class MultiHandler2(HttpLogHandler, MultiHTTPHandler):
_logger = logging.getLogger('http')
wbufsize = 32768
class SecureMultiHandler2(HttpLogHandler, SecureMultiHTTPHandler):
_logger = logging.getLogger('https')
wbufsize = 32768
def getcert_fnames(self):
tc = tools.config
+7 -2
View File
@@ -182,12 +182,13 @@ class FixSendError:
self.send_header('Connection', 'close')
self.send_header('Content-Length', len(content) or 0)
self.end_headers()
if hasattr(self, '_flush'):
self._flush()
if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
self.wfile.write(content)
if hasattr(self, '_flush'):
self._flush()
class HttpOptions:
_HTTP_OPTIONS = {'Allow': ['OPTIONS' ] }
@@ -395,6 +396,7 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
return
if not self.parse_rawline():
self.log_message("Could not parse rawline.")
self.wfile.flush()
return
# self.parse_request(): # Do NOT parse here. the first line should be the only
@@ -403,6 +405,7 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
if not self.parse_request():
return
self.do_OPTIONS()
self.wfile.flush()
return
for vdir in self.server.vdirs:
@@ -429,9 +432,11 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
"client closed connection", self.rlpath.rstrip())
else:
raise
self.wfile.flush()
return
# if no match:
self.send_error(404, "Path not found: %s" % self.path)
self.wfile.flush()
return
def _get_ignore_body(self,fore):
+1 -9
View File
@@ -61,15 +61,7 @@ class mysocket:
def mysend(self, msg, exception=False, traceback=None):
msg = cPickle.dumps([msg,traceback])
size = len(msg)
self.sock.send('%8d' % size)
self.sock.send(exception and "1" or "0")
totalsent = 0
while totalsent < size:
sent = self.sock.send(msg[totalsent:])
if sent == 0:
raise RuntimeError, "socket connection broken"
totalsent = totalsent + sent
self.sock.sendall('%8d%s%s' % (len(msg), exception and "1" or "0", msg))
def myreceive(self):
buf=''