Exemplo n.º 1
0
 def prepConnection(self):
     if not self.query or 'c' not in self.query:
         self.sendHeaders({'status': '500 Internal Server Error'})
         SessionProtocol.write(self, '"callback" parameter required')
         self.loseConnection()
         return True
     self.sendHeaders()
Exemplo n.º 2
0
 def write(self, data):
     packet = "<script>\np(\"%s\");\n</script>\r\n" % data.replace(
         '\\', '\\\\').replace('"', '\\"')
     self.sent += len(packet)
     SessionProtocol.write(self, packet)
     if self.sent > self.factory.options['streaming_limit']:
         self.loseConnection()
Exemplo n.º 3
0
 def prepConnection(self):
     if not self.query or 'c' not in self.query:
         self.sendHeaders({'status': '500 Internal Server Error'})
         SessionProtocol.write(self, '"callback" parameter required')
         self.loseConnection()
         return True
     self.sendHeaders()
Exemplo n.º 4
0
 def write(self, data):
     if self.written:
         self.wrappedProtocol.requeue([data])
         return
     packet = "%s(\"%s\");\r\n" % (self.query['c'][0], data.replace('\\','\\\\').replace('"','\\"'))
     SessionProtocol.write(self, packet)
     self.written = True
     self.loseConnection()
Exemplo n.º 5
0
 def write(self, data):
     if self.written:
         self.wrappedProtocol.requeue([data])
         return
     packet = "%s\n" % data
     SessionProtocol.write(self, packet)
     self.written = True
     self.loseConnection()
Exemplo n.º 6
0
 def write(self, data):
     if self.written:
         self.wrappedProtocol.requeue([data])
         return
     packet = "%s\n" % data
     SessionProtocol.write(self, packet)
     self.written = True
     self.loseConnection()
Exemplo n.º 7
0
 def write(self, data):
     if self.written:
         self.wrappedProtocol.requeue([data])
         return
     packet = "%s(\"%s\");\r\n" % (
         self.query['c'][0], data.replace('\\', '\\\\').replace('"', '\\"'))
     SessionProtocol.write(self, packet)
     self.written = True
     self.loseConnection()
Exemplo n.º 8
0
 def dataReceived(self, data):
     self.buf += data
     if 'Content-Length' in self.headers and len(self.buf) < int(self.headers['Content-Length']):
         return
     data = self.buf
     self.buf = ""
     del self.headers['Content-Length']
     if 'Content-Type' in self.headers and self.headers['Content-Type'] == 'application/x-www-form-urlencoded':
         query = parse_qs(data, True)
         data = query.get('d',[''])[0]
     SessionProtocol.dataReceived(self, data)
Exemplo n.º 9
0
 def dataReceived(self, data):
     self.buf += data
     if 'Content-Length' in self.headers and len(self.buf) < int(
             self.headers['Content-Length']):
         return
     data = self.buf
     self.buf = ""
     del self.headers['Content-Length']
     if 'Content-Type' in self.headers and self.headers[
             'Content-Type'] == 'application/x-www-form-urlencoded':
         query = parse_qs(data, True)
         data = query.get('d', [''])[0]
     SessionProtocol.dataReceived(self, data)
Exemplo n.º 10
0
    def prepConnection(self):
        if not self.query or 'c' not in self.query:
            self.sendHeaders({'status': '500 Internal Server Error'})
            SessionProtocol.write(self, '"callback" parameter required')
            self.loseConnection()
            return True
        self.sendHeaders()
        SessionProtocol.write(self, r'''
<!doctype html>
<html><head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head><body><h2>Don't panic!</h2>
  <script>
    document.domain = document.domain;
    var c = parent.%s;
    c.start();
    function p(d) {c.message(d);};
    window.onload = function() {c.stop();};
  </script>%s
''' % (self.query['c'][0], ' '*1024))
Exemplo n.º 11
0
    def prepConnection(self):
        if not self.query or 'c' not in self.query:
            self.sendHeaders({'status': '500 Internal Server Error'})
            SessionProtocol.write(self, '"callback" parameter required')
            self.loseConnection()
            return True
        self.sendHeaders()
        SessionProtocol.write(
            self, r'''
<!doctype html>
<html><head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head><body><h2>Don't panic!</h2>
  <script>
    document.domain = document.domain;
    var c = parent.%s;
    c.start();
    function p(d) {c.message(d);};
    window.onload = function() {c.stop();};
  </script>%s
''' % (self.query['c'][0], ' ' * 1024))
Exemplo n.º 12
0
 def sendBody(self):
     self.sendHeaders({'Content-Length': '2'})
     SessionProtocol.write(self, 'ok')
Exemplo n.º 13
0
 def prepConnection(self):
     self.sendHeaders()
     SessionProtocol.write(self, 'h'*2048+"\n")
Exemplo n.º 14
0
 def write(self, data):
     packet = "<script>\np(\"%s\");\n</script>\r\n" % data.replace('\\','\\\\').replace('"','\\"')
     self.sent += len(packet)
     SessionProtocol.write(self, packet)
     if self.sent > self.factory.options['streaming_limit']:
         self.loseConnection()
Exemplo n.º 15
0
 def sendBody(self):
     self.sendHeaders({'Content-Length':'2'})
     SessionProtocol.write(self, 'ok')
Exemplo n.º 16
0
 def sendHeaders(self, headers = {}):
     h = {'status': '204 No Body'}
     h.update(headers)
     SessionProtocol.sendHeaders(self, h)
Exemplo n.º 17
0
 def write(self, data):
     packet = "%s\n" % data
     self.sent += len(packet)
     SessionProtocol.write(self, packet)
     if self.sent > self.factory.options['streaming_limit']:
         self.loseConnection()
Exemplo n.º 18
0
 def prepConnection(self):
     self.sendHeaders()
     SessionProtocol.write(self, 'h' * 2048 + "\n")
Exemplo n.º 19
0
 def sendHeaders(self, headers={}):
     h = {'status': '204 No Body'}
     h.update(headers)
     SessionProtocol.sendHeaders(self, h)
Exemplo n.º 20
0
 def prepConnection(self):
     self.sendHeaders()
     SessionProtocol.write(self, "\r\n")
Exemplo n.º 21
0
 def write(self, data):
     packet = "data: %s\r\n\r\n" % data
     self.sent += len(packet)
     SessionProtocol.write(self, packet)
     if self.sent > self.factory.options['streaming_limit']:
         self.loseConnection()
Exemplo n.º 22
0
 def prepConnection(self):
     self.sendHeaders()
     SessionProtocol.write(self, "\r\n")