def do_POST(self): self._sessions.acquire_lock() try: proposed_session_id = self._extract_session_id() session_id = self._sessions.get_valid_session_id( proposed_session_id) content_length = self.headers.dict.get("content-length", None) if content_length is not None: raw_post_data = self.rfile.read(int(content_length)) path, values = lib.split_url(self.path) logger.debug( "http post %s for session: %s" % (path, session_id)) location = self._locations.get(path) if location: try: wfile = cStringIO.StringIO() post_data = self._decode_raw_post_data(raw_post_data) location.handle_post(session_id, values, post_data, wfile) self._send_standard_header(session_id, location.mime_type) self.wfile.write(wfile.getvalue()) except RedirectException, e: self._send_redirect(e.path) except Exception: self._send_exception()
def do_GET(self): self._sessions.acquire_lock() try: proposed_session_id = self._extract_session_id() session_id = self._sessions.get_valid_session_id( proposed_session_id) path, values = lib.split_url(self.path) host = self.client_address[0] logger.debug("http get %s from host %s (session %s)" % (path, host, session_id)) location = self._locations.get(path) if location: try: wfile = cStringIO.StringIO() location.handle_get(session_id, values, wfile) self._send_standard_header(session_id, location.mime_type) self.wfile.write(wfile.getvalue()) except RedirectException, e: self._send_redirect(e.path) except Exception: self._send_exception()