def __init__(self, *args, **kwargs): from django.conf import settings self.admin_media_prefix = settings.ADMIN_MEDIA_PREFIX # We set self.path to avoid crashes in log_message() on unsupported # requests (like "OPTIONS"). self.path = '' BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def send_response(self, code: Union[int, HTTPStatus], message=None): """Fill in HTTP status message if not set.""" if message is None: if isinstance(code, HTTPStatus): message = code.phrase code = code.value BaseHTTPRequestHandler.send_response(self, code=code, message=message)
def finish(self): """make python2 BaseHTTPRequestHandler happy""" try: BaseHTTPRequestHandler.finish(self) except (IOError, OSError) as e: if e[0] not in (errno.ECONNABORTED, errno.ECONNRESET, errno.EPIPE): raise
def __init__(self, *args, **kwargs): from google.appengine._internal.django.conf import settings self.admin_media_prefix = settings.ADMIN_MEDIA_PREFIX # We set self.path to avoid crashes in log_message() on unsupported # requests (like "OPTIONS"). self.path = '' self.style = color_style() BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, request, client_address, origin): self.origin = origin #if __name__ != '__main__': # self.origin.log('postman initializing as plugin..', 2) #else: # self.origin.log('postman initializing as standalone application..', 2) # ^ works BaseHTTPRequestHandler.__init__(self, request, client_address, origin)
def __init__(self, request, client_address, server): ''' :param request: the request from the client :param client_address: client address :param server: HTTP server ''' BaseHTTPRequestHandler.__init__( self, request, client_address, server) self.dataman = None
def __init__(self, request, client_address, server): try: mimetypes.init() self.DebugMode = False BaseHTTPRequestHandler.__init__(self, request, client_address, server) except: ReportException()
def __init__(self, *args, **kwargs): sock = socket_wrapper.Socket(unix_socket=True) sock.make_nonblocking() if not sock.connect_unix(os.path.expanduser(PETTYCOIN_SOCKET)): logging.error('Could not open socket: {}'.format(PETTYCOIN_SOCKET)) sys.exit(1) self.petty_sock = sock self.petty_reader = JsonSocketReader(sock) self.html_parser = HTMLParser() BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, http_svc, *args, **kwargs): """ Sets up the request handler (called for each request) :param http_svc: The associated HTTP service """ self._service = http_svc # This calls the do_* methods BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def test(handler): sess_id = handler.query.split('=',1)[1] handler.send_response(200) handler.send_header("Content-type", "text/html") msg = "{}={}".format(sess_id, 1000) handler.send_header("Content-length", str(len(msg))) handler.send_header("Connection", "close") handler.end_headers() BaseHTTPRequestHandler.end_headers(handler) handler.wfile.write("{}!".format(msg))
def __init__(self, http_svc, *args, **kwargs): """ Constructor :param http_svc: The associated HTTP service instance """ # Store the reference to the service self.service = http_svc # Call the parent constructor BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, request, client, server): request.settimeout(60.) try: BaseHTTPRequestHandler.__init__(self, request, client, server) except OSError as e: if server.debug: logger.exception("OSError in http request") else: logger.error("%s", e) except Exception: logger.exception("Unhandle Error")
def log_message(self, *args, **kwargs): if self.command == 'POST': sys.stderr.write('{addr} - - [{datetime}] "POST {path} {req_ver}" {statuscode} {data}\n'.format( addr=self.address_string(), datetime=self.log_date_time_string(), path=self.path, req_ver=self.request_version, statuscode=args[2], data=self.POST_data.decode(), )) else: BaseHTTPRequestHandler.log_message(self, *args, **kwargs)
def handle_one_request(self): """Extended request handler This is where WebSocketRequestHandler redirects requests to the new methods. Any sub-classes must call this method in order for the calls to function. """ self._real_do_GET = self.do_GET self.do_GET = self._websocket_do_GET try: BaseHTTPRequestHandler.handle_one_request(self) finally: self.do_GET = self._real_do_GET
def send_response(self, mesg, code=200, headers=None): 'Wraps sending a response down' if not headers: headers = {} if 'Content-Type' not in headers: headers['Content-Type'] = 'text/html' BaseHTTPRequestHandler.send_response(self, code) self.send_header('Content-Length', len(mesg)) if headers: for k, v in headers.items(): self.send_header(k, v) self.end_headers() self.wfile.write(mesg)
def send_header(BaseHTTPRequestHandler): BaseHTTPRequestHandler.send_response(200) BaseHTTPRequestHandler.send_header('Access-Control-Allow-Origin', '*') BaseHTTPRequestHandler.send_header('Content-type:', 'text/html') BaseHTTPRequestHandler.end_headers() BaseHTTPRequestHandler.wfile.write(bytes('\n', 'utf-8')) BaseHTTPRequestHandler.wfile.write(bytes('<html>\n', 'utf-8'))
def __init__(self, request, client_address, server): """ override default baseHTTP info add some variables like: cookies, query, path, etc. """ self.server_version = 'Thorin/1.0.3' self.request_version = 'HTTP/1.1' self.sys_version = '' self.response_time = time.time() self.cookies = {} self.query = {} self.path = {} self.remote_ip = '' BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def handle(self): """Handles a request ignoring dropped connections.""" rv = None try: rv = BaseHTTPRequestHandler.handle(self) except (socket.error, socket.timeout, ssl.SSLError) as e: self.connection_dropped(e) return rv
def handle_one_request(self): """Catch more exceptions than default Intend to catch exceptions on local side Exceptions on remote side should be handled in do_*() """ try: BaseHTTPRequestHandler.handle_one_request(self) return except (ConnectionError, FileNotFoundError) as e: logger.warning("%03d " % self.reqNum + Fore.RED + "%s %s", self.server_version, e) except (ssl.SSLEOFError, ssl.SSLError) as e: if hasattr(self, 'url'): # Happens after the tunnel is established logger.warning("%03d " % self.reqNum + Fore.YELLOW + '"%s" while operating on established local SSL tunnel for [%s]' % (e, self.url)) else: logger.warning("%03d " % self.reqNum + Fore.YELLOW + '"%s" while trying to establish local SSL tunnel for [%s]' % (e, self.path)) self.close_connection = 1
def handle_one_request(self): """Extended request handler This is where WebSocketRequestHandler redirects requests to the new methods. Any sub-classes must call this method in order for the calls to function. """ self._real_do_GET = self.do_GET self.do_GET = self._websocket_do_GET try: # super() only works for new style classes if issubclass(WebSocketRequestHandlerMixIn, object): super(WebSocketRequestHandlerMixIn, self).handle_one_request() else: # Assume handle_one_request() hasn't been overriden BaseHTTPRequestHandler.handle_one_request(self) finally: self.do_GET = self._real_do_GET
def __init__(self, request, client_address, server, cpu): log.error("ControlHandler %s %s %s", request, client_address, server) self.cpu = cpu self.get_urls = { r"/disassemble/(\s+)/$": self.get_disassemble, r"/memory/(\s+)(-(\s+))?/$": self.get_memory, r"/memory/(\s+)(-(\s+))?/raw/$": self.get_memory_raw, r"/status/$": self.get_status, r"/$": self.get_index, } self.post_urls = { r"/memory/(\s+)(-(\s+))?/$": self.post_memory, r"/memory/(\s+)(-(\s+))?/raw/$": self.post_memory_raw, r"/quit/$": self.post_quit, r"/reset/$": self.post_reset, r"/debug/$": self.post_debug, } BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def parse_request(self): r = BaseHTTPRequestHandler.parse_request(self) if r: v = self.request_version if v == "HTTP/1.1" or v == "HTTP/1.0" : self.protocol_version = v t = urlparse(self.path) self.path = t.path self.query = t.query self.params = t.params self.fragment = t.fragment return r
def handle(self): """Handles a request ignoring dropped connections.""" rv = None try: rv = BaseHTTPRequestHandler.handle(self) except (_ConnectionError, socket.timeout) as e: self.connection_dropped(e) except Exception as e: if self.server.ssl_context is None or not is_ssl_error(e): raise if self.server.shutdown_signal: self.initiate_shutdown() return rv
def __init__(self, *args, **kwargs): """ """ global Gd_internalvar self.__name__ = 'StoreHandler' self.d_ctlVar = Gd_internalvar b_test = False self.b_useDebug = False self.str_debugFile = '/tmp/pfioh-log.txt' self.b_quiet = True self.dp = pfmisc.debug( verbosity = 0, level = -1, within = self.__name__ ) self.pp = pprint.PrettyPrinter(indent=4) for k,v in kwargs.items(): if k == 'test': b_test = True if not b_test: BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, request, client_address, server): self.response_status_code = None self.response_headers = {} self.response_body = None PactRequestHandler.__init__(self, server.pact) BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def __init__(self, *args, **kwargs): BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.tls = threading.local() self.tls.conns = {} BaseHTTPRequestHandler.__init__(self, *args, *kwargs)
def __init__(self, request, client_addr, server): self.is_connected = False self._target = None BaseHTTPRequestHandler.__init__(self, request, client_addr, server)
def __init__(self, *args, **kwargs): self.user = None BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, logger, version, devices, actions, *args): self.logger = logger self.version = version self.devices = devices self.actions = actions BaseHTTPRequestHandler.__init__(self, *args)
def version_string(self): return BaseHTTPRequestHandler.version_string(self).strip()
def end_headers(self): self.send_header('Access-Control-Allow-Origin', '*') BaseHTTPRequestHandler.end_headers(self)
def __init__(self, app_handlers, *args): self.app_handlers = app_handlers BaseHTTPRequestHandler.__init__(self, *args)
def __init__(self, request, client_address, server): print("init") # self.nlp = spacy.load("ja_ginza") BaseHTTPRequestHandler.__init__(self,request,client_address,server)
def __init__(self, queue, *args): self.queue = queue BaseHTTPRequestHandler.__init__(self, *args)
def setup(self): self.timeout = 90000 BaseHTTPRequestHandler.setup(self) self.request.settimeout(90000)
def __init__(self, request, address, server): self.__server = server self.tree = server.tree BaseHTTPRequestHandler.__init__(self, request, address, server)
def setup(self): global args ret = BaseHTTPRequestHandler.setup(self) self.request.settimeout(args.timeout) return ret
def initialize_handler(httpHandler: BaseHTTPRequestHandler): """Used to initialize the remote playlist via Spotify's API""" response = httpHandler.player.initialize() httpHandler.output_headers() httpHandler.wfile.write(json.dumps(response).encode())
def end_headers(self): self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Methods', '*') self.send_header('Access-Control-Allow-Headers', 'Content-Type') BaseHTTPRequestHandler.end_headers(self)
def __init__(self, *args): self.sinkname = self.__class__.__name__ BaseHTTPRequestHandler.__init__(self, *args)
def log_request(self, code="-", size="-"): """Selectively log an accepted request.""" if self.server.logRequests: BaseHTTPRequestHandler.log_request(self, code, size)
def __init__(self, *args, debug): self.EMG_data = [] self.debug = debug BaseHTTPRequestHandler.__init__(self, *args)
def __init__(self, *args): self.logFile = open('messages.log', 'a') BaseHTTPRequestHandler.__init__(self, *args)
def __init__(self, request, client_address, server): BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def __init__(self, request, client_address, server): """ Regular constructor, an instance is created for each request, do not store any data for a longer time than a request. """ BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def log_request(self, code='-', size='-'): if code == 200: BaseHTTPRequestHandler.log_request(self, code, size)
def __init__(s, functionPost, functionGet, argument, *args): s.postProcess = functionPost s.getProcess = functionGet s.processArg = argument BaseHTTPRequestHandler.__init__(s, *args)
def __init__(self, request, client_address, server): self.auth = b'Basic ' + base64.encodebytes(b'test:test')[:-1] self.count = 0 BaseHTTPRequestHandler.__init__(self, request, client_address, server)
def start_login_handler(httpHandler: BaseHTTPRequestHandler): """Used to handle the start of the authorization with Spotify""" response = httpHandler.player.start_login() httpHandler.output_headers() httpHandler.wfile.write(json.dumps(response).encode())
def __init__(self, cutouts, *args): self.cutouts = cutouts BaseHTTPRequestHandler.__init__(self, *args)
def complete_login_handler(httpHandler: BaseHTTPRequestHandler): """Used to hanbdle the completion of the authorization with Spotify""" query = urlparse(httpHandler.path)[4] query_dict = dict(parse_qsl(query)) httpHandler.player.complete_login(**query_dict) httpHandler.output_headers()
def __init__(self, config, *args): self.sender = config.sender BaseHTTPRequestHandler.__init__(self, *args)
def end_headers(self): self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Content-Type', 'application/json') BaseHTTPRequestHandler.end_headers(self)
def __init__(self, ctx, DocumentRoot, *args): self._ctx = ctx self.DocumentRoot = DocumentRoot BaseHTTPRequestHandler.__init__(self, *args)
def __init__(self, *args): BaseHTTPRequestHandler.__init__(self, *args)
def log_request(self, code='-', size='-'): """Selectively log an accepted request.""" if self.server.logRequests: BaseHTTPRequestHandler.log_request(self, code, size)
def __init__(self): BaseHTTPRequestHandler.__init__(self) self.responder = MailResponder()
def setup(self): BaseHTTPRequestHandler.setup(self) self.request.settimeout(2)