Exemple #1
0
    def snapshot_cont(self):
        info = self.manager.browser_mgr.init_cont_browser_sesh()
        if not info:
            return {
                'error_message': 'conn not from valid containerized browser'
            }

        user = info['user']
        coll = info['coll']

        browser = info['browser']

        url = request.query.getunicode('url')

        title = request.query.getunicode('title')

        html_text = request.body.read().decode('utf-8')

        referrer = request.environ.get('HTTP_REFERER', '')

        user_agent = request.environ.get('HTTP_USER_AGENT')

        noprewriter = NopRewriter()
        html_unrewriter = HTMLDomUnRewriter(noprewriter)

        html_text = html_unrewriter.unrewrite(html_text)

        origin = request.environ.get('HTTP_ORIGIN')
        if origin:
            response.headers['Access-Control-Allow-Origin'] = origin

        return self.write_snapshot(user, coll, url, title, html_text, referrer,
                                   user_agent, browser)
Exemple #2
0
    def snapshot(self):
        user, coll = self.get_user_coll(api=True)

        if not self.manager.has_collection(user, coll):
            return {'error_message' 'collection not found'}

        html_text = request.body.read().decode('utf-8')

        host = request.urlparts.scheme + '://'
        if self.content_host:
            host += self.content_host
        else:
            host += request.urlparts.netloc

        prefix = request.query.getunicode('prefix')

        url = request.query.getunicode('url')

        user_agent = request.environ.get('HTTP_USER_AGENT')

        title = request.query.getunicode('title')

        unrewriter = UnRewriter(host, prefix)

        referrer = request.environ.get('HTTP_REFERER', '')
        referrer = unrewriter.rewrite(referrer)

        html_unrewriter = HTMLDomUnRewriter(unrewriter)

        html_text = html_unrewriter.unrewrite(html_text, host=host)

        return self.write_snapshot(user, coll, url, title, html_text, referrer,
                                   user_agent)
    def snapshot_cont(self):
        info = self.browser_mgr.init_remote_browser_session()
        if not info:
            return {'error_message': 'conn not from valid containerized browser'}

        user = info['the_user']
        collection = info['collection']

        browser = info['browser']

        url = request.query.getunicode('url')

        title = request.query.getunicode('title')

        html_text = request.body.read().decode('utf-8')

        referrer = request.environ.get('HTTP_REFERER', '')

        user_agent = request.environ.get('HTTP_USER_AGENT')

        noprewriter = NopRewriter()
        html_unrewriter = HTMLDomUnRewriter(noprewriter)

        html_text = html_unrewriter.unrewrite(html_text)

        origin = request.environ.get('HTTP_ORIGIN')
        if origin:
            response.headers['Access-Control-Allow-Origin'] = origin

        #TODO
        return self.write_snapshot(user, collection, url,
                                   title, html_text, referrer,
                                   user_agent, browser)
Exemple #4
0
    def snapshot(self):
        user, collection = self.load_user_coll()

        html_text = request.body.read().decode('utf-8')

        host = request.urlparts.scheme + '://'
        if self.content_host:
            host += self.content_host
        else:
            host += request.urlparts.netloc

        prefix = request.query.getunicode('prefix')

        url = request.query.getunicode('url')

        user_agent = request.environ.get('HTTP_USER_AGENT')

        title = request.query.getunicode('title')

        unrewriter = UnRewriter(host, prefix)

        referrer = request.environ.get('HTTP_REFERER', '')
        referrer = unrewriter.rewrite(referrer)

        html_unrewriter = HTMLDomUnRewriter(unrewriter)

        html_text = html_unrewriter.unrewrite(html_text, host=host)

        return self.write_snapshot(user, collection, url, title, html_text,
                                   referrer, user_agent)
    def snapshot(self):
        user, collection = self.load_user_coll()

        html_text = request.body.read().decode('utf-8')

        host = request.urlparts.scheme + '://'
        if self.content_host:
            host += self.content_host
        else:
            host += request.urlparts.netloc

        prefix = request.query.getunicode('prefix')

        url = request.query.getunicode('url')

        user_agent = request.environ.get('HTTP_USER_AGENT')

        title = request.query.getunicode('title')

        unrewriter = UnRewriter(host, prefix)

        referrer = request.environ.get('HTTP_REFERER', '')
        referrer = unrewriter.rewrite(referrer)

        html_unrewriter = HTMLDomUnRewriter(unrewriter)

        html_text = html_unrewriter.unrewrite(html_text, host=host)

        return self.write_snapshot(user, collection, url, title, html_text, referrer, user_agent)