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

Method do_POST

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

POST method handler.

(self)

Source from the content-addressed store, hash-verified

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