MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / do_POST

Method do_POST

py/test/selenium/webdriver/common/webserver.py:182–207  ·  view source on GitHub ↗

POST method handler.

(self)

Source from the content-addressed store, hash-verified

180 self.send_error(404, f"File Not Found: {path}")
181
182 def do_POST(self):
183 """POST method handler."""
184 try:
185 remaining_bytes = int(self.headers.get("content-length", 0))
186 contents = self.rfile.read(remaining_bytes).decode("utf-8")
187
188 path = self.path[1:].split("?")[0]
189
190 if path == "echo_body":
191 self._send_response("text/plain")
192 self.wfile.write(contents.encode("utf-8"))
193 return
194
195 fn_match = re.search(r'Content-Disposition.*name="upload"; filename="(.*)"', contents)
196 if not fn_match:
197 self.send_error(500, f"File not found in content. {contents}")
198 return
199 self._send_response("text/html")
200 self.wfile.write(
201 f"""<!doctype html>
202 {contents}
203 <script>window.top.window.onUploadDone();</script>
204 """.encode()
205 )
206 except Exception as e:
207 self.send_error(500, f"Error found: {e}")
208
209 def log_message(self, format, *args):
210 """Override default to avoid trashing stderr."""

Callers

nothing calls this directly

Calls 8

_send_responseMethod · 0.95
splitMethod · 0.80
getMethod · 0.65
decodeMethod · 0.65
readMethod · 0.65
encodeMethod · 0.65
writeMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected