MCPcopy Index your code
hub / github.com/python/cpython / do_POST

Method do_POST

Lib/xmlrpc/server.py:466–535  ·  view source on GitHub ↗

Handles the HTTP POST request. Attempts to interpret all HTTP POST requests as XML-RPC calls, which are forwarded to the server's _dispatch method for handling.

(self)

Source from the content-addressed store, hash-verified

464 return True
465
466 def do_POST(self):
467 """Handles the HTTP POST request.
468
469 Attempts to interpret all HTTP POST requests as XML-RPC calls,
470 which are forwarded to the server's _dispatch method for handling.
471 """
472
473 # Check that the path is legal
474 if not self.is_rpc_path_valid():
475 self.report_404()
476 return
477
478 try:
479 # Get arguments by reading body of request.
480 # We read this in chunks to avoid straining
481 # socket.read(); around the 10 or 15Mb mark, some platforms
482 # begin to have problems (bug #792570).
483 max_chunk_size = 10*1024*1024
484 size_remaining = int(self.headers["content-length"])
485 L = []
486 while size_remaining:
487 chunk_size = min(size_remaining, max_chunk_size)
488 chunk = self.rfile.read(chunk_size)
489 if not chunk:
490 break
491 L.append(chunk)
492 size_remaining -= len(L[-1])
493 data = b''.join(L)
494
495 data = self.decode_request_content(data)
496 if data is None:
497 return #response has been sent
498
499 # In previous versions of SimpleXMLRPCServer, _dispatch
500 # could be overridden in this class, instead of in
501 # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
502 # check to see if a subclass implements _dispatch and dispatch
503 # using that method if present.
504 response = self.server._marshaled_dispatch(
505 data, getattr(self, '_dispatch', None), self.path
506 )
507 except Exception as e: # This should only happen if the module is buggy
508 # internal error, report as HTTP server error
509 self.send_response(500)
510
511 # Send information about the exception if requested
512 if hasattr(self.server, '_send_traceback_header') and \
513 self.server._send_traceback_header:
514 self.send_header("X-exception", str(e))
515 trace = traceback.format_exc()
516 trace = str(trace.encode('ASCII', 'backslashreplace'), 'ASCII')
517 self.send_header("X-traceback", trace)
518
519 self.send_header("Content-length", "0")
520 self.end_headers()
521 else:
522 self.send_response(200)
523 self.send_header("Content-type", "text/xml")

Callers

nothing calls this directly

Calls 15

is_rpc_path_validMethod · 0.95
report_404Method · 0.95
accept_encodingsMethod · 0.95
gzip_encodeFunction · 0.90
strFunction · 0.85
send_responseMethod · 0.80
send_headerMethod · 0.80
readMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
_marshaled_dispatchMethod · 0.45

Tested by

no test coverage detected