def do_GET(self): if self.path == '/': self.send_response(301) self.send_header("Location", "/cgi-bin/index.py") self.end_headers() else: CGIHTTPRequestHandler.do_GET(self)
def do_GET(self): """Serve a GET request.""" if not self.allow_path(): self.send_error(403) elif self.is_brat(): self.run_brat_direct() else: CGIHTTPRequestHandler.do_GET(self)
def do_GET(self): """ Present frontpage with user authentication. """ if self.headers.getheader('Authorization') == None: self.do_AUTHHEAD() self.wfile.write('no auth header received') elif self.headers.getheader('Authorization') == self._basic_auth_key: CGIHTTPRequestHandler.do_GET(self) else: self.do_AUTHHEAD() self.wfile.write('Not authenticated')
def do_GET(self): debug('__do_GET__\n%s'% self.headers) if self.request_filter(): return if self.path.find('.php') != -1: if self.path.find('?') != -1: self.path, self.requete = self.path.split('?', 1) else: self.requete = '' self.php_request() else: CGIHTTPRequestHandler.do_GET(self)
def do_GET(self): auth = self.headers.getheader('Authorization') if auth is None: self.do_AUTHHEAD() self.wfile.write('no auth') elif auth in self.KEYS: CGIHTTPRequestHandler.do_GET(self) else: self.do_AUTHHEAD() self.wfile.write(auth) self.wfile.write('bad auth')
def do_GET(self, *args, **kwargs): if self.path == "/favicon.ico": protocol, data = favicon.split(",") scheme, info = protocol.split(":") mimetype, rest = info.split(";") self.send_response(200) self.send_header("Content-type", mimetype) httpdate = format_date_time(mktime(datetime.utcnow().timetuple())) self.send_header("Last-Modified", httpdate) self.end_headers() self.wfile.write(data.decode("base64")) return CGIHTTPRequestHandler.do_GET(self, *args, **kwargs)
def do_GET(self, *args, **kwargs): if self.path == '/favicon.ico': protocol, data = favicon.split(',') scheme, info = protocol.split(':') mimetype, rest = info.split(';') self.send_response(200) self.send_header('Content-type', mimetype) httpdate = format_date_time(mktime(datetime.utcnow().timetuple())) self.send_header('Last-Modified', httpdate) self.end_headers() self.wfile.write(data.decode('base64')) return CGIHTTPRequestHandler.do_GET(self, *args, **kwargs)
def do_POST(self): self._do_pages() or CGIHTTPRequestHandler.do_GET(self)
def do_GET(self): try: #go to deault page. if self.path.endswith("/") or self.path =="": if config.Indexes=="on": self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() f= self.list_directory(config.DocumentRoot+self.path) self.copyfile(f, self.wfile) f.close() return elif config.indexpage=="": self.send_response(302) self.send_header("Location", indexpage) self.end_headers() return else: self.send_response(404) self.path="/index.html" if self.path=='/favicon.ico': return path_parts = self.path.split('.') try: content_type=config.contentTypes[path_parts[-1]] except: if config.page404=="": self.send_response(404) else: self.send_response(302) self.send_header("Location",config.page404) self.end_headers() if config.cgi_moudle=="on" and self.path.endswith(config.cgi_extensions): return CGIHTTPRequestHandler.do_GET(self) else: #do static content f = open(config.DocumentRoot + sep + self.path) #self.path has /test.html #note that this potentially makes every file on your computer readable by the internet fs = os.fstat(f.fileno()) Expirestype=config.Expires[-1:] Expirenum=config.Expires[:-1] #set Expires expiration = pubutil.get_http_expiry(Expirestype,int(Expirenum)) #set max-age CACHE_MAX_AGE=pubutil.secs_from_days(config.ExpiresTypes[Expirestype],int(Expirenum)) cache_control = 'public; max-age=%d' % (CACHE_MAX_AGE, ) client_cache_cc = self.headers.getheader('Cache-Control') client_cache_p = self.headers.getheader('Pragma') Modified_Since= self.headers.getheader('If-Modified-Since') if client_cache_cc=='no-cache' or client_cache_p=='no-cache' or \ (client_cache_cc==None and client_cache_p==None and Modified_Since==None): client_modified=None else: try: client_modified = Modified_Since.split(';')[0] except: client_modified=None file_last_modified=self.date_time_string(fs.st_mtime) if client_modified==file_last_modified: self.send_response(304) self.end_headers() else: if config.gzip=="on": compressed_content = pubutil.compressBuf(f.read(),config.compresslevel) else: compressed_content = f.read() self.send_response(200) self.send_header('Last-Modified', file_last_modified) self.send_header('Cache-Control', cache_control) self.send_header('Expires', expiration) self.send_header('Content-type',content_type) if config.gzip=="on": self.send_header('Content-Encoding','gzip') self.send_header ("Content-Length", str(len(compressed_content))) self.end_headers() self.wfile.write(compressed_content) f.close() return return except IOError, e: logger.error(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"-"+str(e))
def do_GET(self): try: # go to default page if self.path.endswith("/"): if Indexes=="on": self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() f = self.list_directory(DocumentRoot+self.path) self.copyfile(f, self.wfile) f.close() return elif indexpage != "": self.send_response(302) self.send_header("Location", indexpage) self.end_headers() return else: self.send_response(404) if self.path=='/favicon.ico': return path_parts = self.path.split('.') try: content_type=contentTypes[path_parts[-1]] except: if page404=="": self.send_response(404) else: self.send_response(302) self.send_header("Location", page404) self.end_headers() if cgi_moudle == "on" and self.path.endswith(cgi_extensions): return CGIHTTPRequestHandler.do_GET(self) else: #static content f = open(DocumentRoot+sep+self.path) fs = os.fstat(f.fileno()) Expirestype = Expires[-1:] Expiresnum=Expires[:-1] expiration = pubutil.get_http_expiry(Expirestype, int(Expiresnum)) CACHE_MAX_AGE = pubutil.secs_from_days(ExpiresTypes[Expirestype], int(Expiresnum)) cache_control = 'public; max_age=%d' % (CACHE_MAX_AGE,) client_cache_cc = self.headers.getheader('Cache-Control') client_cache_p = self.headers.getheader('Pragma') ModifiedSince = self.headers.getheader('If-Modified-Since') if client_cache_cc=='no-cache' or client_cache_p == 'no-cache' or\ (client_cache_p == None and client_cache_cc == None and ModifiedSince == None): client_modified = None else: try: client_modified = ModifiedSince.split(';')[0] except: client_modified = None file_last_modified = self.date_time_string(fs.st_mtime) if client_modified == file_last_modified: self.send_response(304) self.end_headers() else: s = f.read() if gzip == 'on': compressed_content = pubutil.compressBuf(s, compresslevel) else: compressed_content = s self.send_response(202) self.send_header('Last-Modified', file_last_modified) self.send_header('Cache-Control', cache_control) self.send_header('Expires', expiration) self.send_header('Content-type', content_type) if gzip == 'on': self.send_header('Content-Encoding','gzip') self.send_header('Content-Length', str(len(compressed_content))) self.end_headers() self.wfile.write(compressed_content) f.close() return return except IOError, e: logger.error(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"-"+str(e))
def do_GET(self): if self.is_internal(): self.__do_internal() else: CGIHTTPRequestHandler.do_GET(self);
def do_GET(self): try: CGIHTTPRequestHandler.do_GET(self) except: pass
def do_GET(self): try: # go to deault page. if self.path.endswith("/"): if Indexes == "on": self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() f = self.list_directory(DocumentRoot + self.path) self.copyfile(f, self.wfile) f.close() return elif indexpage != "": self.send_response(302) self.send_header("Location", indexpage) self.end_headers() return else: self.send_response(404) if self.path == "/favicon.ico": return path_parts = self.path.split(".") try: content_type = contentTypes[path_parts[-1]] except: if page404 == "": self.send_response(404) else: self.send_response(302) self.send_header("Location", page404) self.end_headers() if cgi_moudle == "on" and self.path.endswith(cgi_extensions): return CGIHTTPRequestHandler.do_GET(self) else: # do static content f = open(DocumentRoot + sep + self.path) # self.path has /test.html # note that this potentially makes every file on your computer readable by the internet fs = os.fstat(f.fileno()) Expirestype = Expires[-1:] Expirenum = Expires[:-1] # set Expires expiration = pubutil.get_http_expiry(Expirestype, int(Expirenum)) # set max-age CACHE_MAX_AGE = pubutil.secs_from_days(ExpiresTypes[Expirestype], int(Expirenum)) cache_control = "public; max-age=%d" % (CACHE_MAX_AGE,) client_cache_cc = self.headers.getheader("Cache-Control") client_cache_p = self.headers.getheader("Pragma") Modified_Since = self.headers.getheader("If-Modified-Since") if ( client_cache_cc == "no-cache" or client_cache_p == "no-cache" or (client_cache_cc == None and client_cache_p == None and Modified_Since == None) ): client_modified = None else: try: client_modified = Modified_Since.split(";")[0] except: client_modified = None file_last_modified = self.date_time_string(fs.st_mtime) if client_modified == file_last_modified: self.send_response(304) self.end_headers() else: if gzip == "on": compressed_content = pubutil.compressBuf(f.read(), compresslevel) else: compressed_content = f.read() self.send_response(200) self.send_header("Last-Modified", file_last_modified) self.send_header("Cache-Control", cache_control) self.send_header("Expires", expiration) self.send_header("Content-type", content_type) if gzip == "on": self.send_header("Content-Encoding", "gzip") self.send_header("Content-Length", str(len(compressed_content))) self.end_headers() self.wfile.write(compressed_content) f.close() return return except IOError, e: logger.error(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + "-" + str(e))
def do_GET(self): print "PATH", self.path SimpleHandler.do_GET(self)
def do_GET(self): self.redirect_path() CGIHTTPRequestHandler.do_GET(self)