Example #1
0
 def post(self):
     input_url = url_tools.validate_url(self.request.get("url_entry"), self.context);
     
     if input_url:
         self.context['input_url'] = input_url
         self.context['mirror_url'] = config.PROXY_SITE + input_url
         self.response.out.write(template.render('template/proxy.html', self.context))
     else:
         logging.debug("user entered invalid input_url %s" % input_url)
         return self.redirect("/")
Example #2
0
    def mirror_url(self, target_url):
        
        target_url = url_tools.validate_url(target_url)
        
        if not target_url:
            logging.debug("user entered invalid input_url %s" % target_url)
            return self.redirect("/")

        mirror_url = HTTP_PREFIX + target_url # the URL the proxy is attempting to mirror
        mirror_content = self.get_mirror_content(mirror_url)
        
        if mirror_content is None:
            return self.error(404)
        
        # TODO: investigate why self.response.headers = mirror_content.headers doesn't work
        
        # write out the response payload 
        for key in mirror_content.headers.keys():
            self.response.headers[key] = mirror_content.headers[key]
            
        self.response.out.write(mirror_content.content)