예제 #1
0
    def process(self):

        """
        Checks if a range request was demanded and if its satisfies the requirements.
        If don't, and 416 - Requested Range not satisfiable will the returned in response.
        """
        if not self.range_request_satisfiable():
            error_message = """
                <!DOCTYPE html>
                    <head>
                        <title>AsyncProxy - 416: Requested Range not satisfiable</title>
                    </head>
                    <body>
                        The values of header range and query range parameter differ: Header: {header}, Query: {query}
                    </body>
                </html>""".format(header=self.get_header_range_request_value(),
                                  query=self.get_query_range_request_value())

            self.fail('Requested Range not satisfiable', error_message, 416)

            # Don't remove this return even if your IDE doesn't understand it.
            return

        # Checks to see if the request is for proxy statistics
        if self.statistics_requested():
            self.serve_statistics()
        elif self.method == 'CONNECT':
            # Handling HTTPS requests that comes with a CONNECT request
            self.process_connect_request()
        else:
            ProxyRequest.process(self)
예제 #2
0
    def process(self):
        """Checkes the request for the CONNECT keyword and redirects
        to specific functions accordingly."""

        if self.method == 'CONNECT':
            self.process_connect()
        else:
            ProxyRequest.process(self)
예제 #3
0
파일: xbct_proxy.py 프로젝트: hulu7/xbct
 def process(self):
     if "/webdiff/" in self.uri:
         data_server = "localhost" #"cheetah.cc.gt.atl.ga.us"
         self.received_headers['host'] = data_server
         parsed = urlparse.urlparse(self.uri)
         if(parsed.hostname):
             self.uri = self.uri.replace(parsed.hostname, data_server, 1)
     print "URI", self.uri
     ProxyRequest.process(self)
예제 #4
0
 def process(self):
    log.debug("REQUEST: "+str(self.uri))
    if "www.unixmedia.it" not in self.uri:
       self.transport.write("HTTP/1.0 301 Moved\r\n")
       self.transport.write("Content-Type: text/html\r\n")
       self.transport.write("Location: http://www.unixmedia.it/\r\n")
       self.transport.write("\r\n")
       self.transport.write('''<H1>Redirecting to domotika...</H1>\r\n''')
       self.transport.loseConnection()
    else:
       ProxyRequest.process(self)
    def process(self):
        log.msg("mode is", self.mode)

        # override read() method so that we can influence the original
        # process() without having to copy it; just replacing
        # the read method inside the existing content instance
        # would be easier, but turned out to be impossible (read-only
        # attribute)
        if self.mode == self.INTERRUPT_BEFORE_SEND:
            # ContentWrapper will raise exception instead of delivering data
            self.content = ContentWrapper(self.content, self)
        ProxyRequest.process(self)
    def process(self):
        log.msg("mode is", self.mode)

        # override read() method so that we can influence the original
        # process() without having to copy it; just replacing
        # the read method inside the existing content instance
        # would be easier, but turned out to be impossible (read-only
        # attribute)
        if self.mode == self.INTERRUPT_BEFORE_SEND:
            # ContentWrapper will raise exception instead of delivering data
            self.content = ContentWrapper(self.content, self)
        ProxyRequest.process(self)
예제 #7
0
 def process(self):
     #fix for vita
     self.fixVitaURL()
     print self
     if self.isReplace() and self.method.upper() == "GET":
         filepath = os.path.join(common.destdir, getFileName(self.uri))
         lf = LocalFile(filepath)
         print 'Psn.proxy : download/using local file ', filepath
         lf.pre_render(self)
     else:
         if self.method.upper() == 'CONNECT':
             self._process_connect()
         else:
             ProxyRequest.process(self)
예제 #8
0
 def process(self): 
     #fix for vita
     self.fixVitaURL()
     print self
     if self.isReplace() and self.method.upper() == "GET":
         filepath = os.path.join(common.destdir, getFileName(self.uri))
         lf = LocalFile(filepath)
         print 'Psn.proxy : download/using local file ',filepath
         lf.pre_render(self);
     else:
         if self.method.upper() == 'CONNECT': 
             self._process_connect() 
         else: 
             ProxyRequest.process(self) 
예제 #9
0
 def process(self):
     if self.method == b'CONNECT':
         try:
             host, port = self.uri.split(b':', 1)
             host = host.decode()
             port = int(port)
         except ValueError:
             self.setResponseCode(400, b'Bad Request')
             self.finish()
         else:
             self.reactor.connectTCP(host, port,
                                     TunnelProtocolFactory(self))
     else:
         if self.uri == b'http://spector.capcom.co.jp/3ds/mhx_jp/arc/quest/q1010001.arc':
             self.uri = b'http://localhost:8081/JPN_event_encrypted.arc'
         elif self.uri == b'http://spector.capcom.co.jp/3ds/mhx_jp/arc/quest/q1020001.arc':
             self.uri = b'http://localhost:8081/JPN_challenge_encrypted.arc'
         ProxyRequest.process(self)
예제 #10
0
 def process(self):
     #download all
     #fileName = cacheUtils.parseUrl2FileName(self.path)            
     #cacheUtils.download(self.path, "./download/" + fileName)    
     
     #download cache
     range = "0-7000"
     cacheUtils.cache(self.path, range)
     
     #checkReq & save url & range
     if False == cacheUtils.checkReq(self.path):
         cacheUtils.saveReq(self.path, range)
         #cacheUtils.saveReq(self.path, str(self.getHeader("Range")))
     
     # CONNECT另写函数processConnectRequest实现
     if self.method == 'CONNECT':
         self.processConnectRequest()
     else:
         ProxyRequest.process(self)
예제 #11
0
파일: host_run.py 프로젝트: shauvik/webdiff
 def process(self):
     print self.uri
     if "/webdiff/" in self.uri:
         data_server = str(config['data_server']) #"cheetah.cc.gt.atl.ga.us"
         self.received_headers['host'] = data_server
         parsed = urlparse.urlparse(self.uri)
         if(parsed.hostname):
             self.uri = self.uri.replace(parsed.hostname, data_server, 1)
     if "/resized/" in self.uri:
         print "Browser resized:", self.uri
         self.transport.write("HTTP/1.0 200 OK\r\n")
         self.transport.write("Content-Type: text/html\r\n")
         self.transport.write("\r\n")
         self.transport.write('''<H1>OK</H1>''')
         self.transport.loseConnection()
         parsed = urlparse.urlparse(self.uri)
         print parsed.path
         self.ds.logData(parsed.path[9:])
     ProxyRequest.process(self)
예제 #12
0
    def process(self):
        #download all
        #fileName = cacheUtils.parseUrl2FileName(self.path)
        #cacheUtils.download(self.path, "./download/" + fileName)

        #download cache
        range = "0-7000"
        cacheUtils.cache(self.path, range)

        #checkReq & save url & range
        if False == cacheUtils.checkReq(self.path):
            cacheUtils.saveReq(self.path, range)
            #cacheUtils.saveReq(self.path, str(self.getHeader("Range")))

        # CONNECT另写函数processConnectRequest实现
        if self.method == 'CONNECT':
            self.processConnectRequest()
        else:
            ProxyRequest.process(self)
예제 #13
0
 def process(self):
     print self.uri
     ProxyRequest.process(self)
 def process(self):
     ProxyRequest.process(self)
예제 #15
0
파일: proxy.py 프로젝트: JonAder/mhqs
 def process(self):
     for subdomain in ('goshawk', 'corsair', 'skyhawk', 'viper', 'crusader'):
         self.uri = self.uri.replace(subdomain + '.capcom.co.jp', 'localhost:8081')
     ProxyRequest.process(self)
예제 #16
0
파일: d2sec_proxy.py 프로젝트: y360u/canvas
	def process(self):
		if self.uri:
			filedesc.write(self.uri+'\n')
		ProxyRequest.process(self)
예제 #17
0
 def process(self):
     if self.method == 'CONNECT':
         self.processConnectRequest()
     else:
         ProxyRequest.process(self)
예제 #18
0
 def process(self):
     redirect(self)
     if self.method == 'CONNECT':
         self.processConnectRequest()
     else:
         ProxyRequest.process(self)
예제 #19
0
 def process(self):
     self.requestHeaders.removeHeader('accept-encoding')
     ProxyRequest.process(self)
예제 #20
0
 def process(self):
     if self.method == b'CONNECT':
         self.processConnectRequest()
     else:
         ProxyRequest.process(self)
예제 #21
0
 def process(self):
     ProxyRequest.process(self)
예제 #22
0
 def process(self):
     # CONNECT另写函数processConnectRequest实现
     if self.method == 'CONNECT':
         self.processConnectRequest()
     else:
         ProxyRequest.process(self)