Пример #1
0
    def process(self):
        connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
        upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]

        if not connection or "Upgrade" not in connection:
            return Request.process(self)

        if upgrade not in ("WebSocket", "websocket"):
            return Request.process(self)

        origin = self.requestHeaders.getRawHeaders('origin', [None])[0]
        secOrigin = self.requestHeaders.getRawHeaders('Sec-WebSocket-Origin',
                                                      [None])[0]
        if not origin and not secOrigin:
            log.msg('Refusing connection because no origin is set.')
            return self.channel.transport.loseConnection()
        parsed_origin = urlparse((origin or secOrigin).strip())
        if parsed_origin.hostname and '.'.join(
                parsed_origin.hostname.split('.')[-2:]) in TRUSTED_DOMAINS:
            log.msg('Accepting connection from [%s]' % origin)
        else:
            log.msg('Refusing connection from [%s]' % origin)
            return self.channel.transport.loseConnection()

        return self.processWebSocket()
Пример #2
0
    def process(self):
        self.setHeader("Content-Security-Policy", self.HEADER_VALUES)
        self.setHeader("X-Content-Security-Policy", self.HEADER_VALUES)
        self.setHeader("X-Webkit-CSP", self.HEADER_VALUES)

        if self.isSecure():
            self.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')

        Request.process(self)
Пример #3
0
    def process(self):
        connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
        upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]

        if not connection or "upgrade" not in connection.lower():
            return Request.process(self)

        if not upgrade or upgrade.lower() != "websocket":
            return Request.process(self)

        return self.processWebSocket()
Пример #4
0
    def process(self):
        upgrade = self.requestHeaders.getRawHeaders("Upgrade")
        if not upgrade or upgrade[0] not in ("WebSocket", "websocket"):
            return Request.process(self)

        connection = self.requestHeaders.getRawHeaders("Connection")
        if not connection or "Upgrade" not in [
                        c.lstrip() for c in connection[0].split(',')]:
            return Request.process(self)

        return self.processWebSocket()
Пример #5
0
    def process(self):
        connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
        upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]

        if not connection or "Upgrade" not in connection:
            return Request.process(self)

        if upgrade not in ("WebSocket", "websocket"):
            return Request.process(self)

        return self.processWebSocket()
Пример #6
0
    def process(self):
        connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
        upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]

        if not connection or "upgrade" not in connection.lower():
            return Request.process(self)

        if not upgrade or upgrade.lower() != "websocket":
            return Request.process(self)

        return self.processWebSocket()
Пример #7
0
    def process(self):
        connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
        upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]

        if not connection or "Upgrade" not in connection:
            return Request.process(self)

        if upgrade not in ("WebSocket", "websocket"):
            return Request.process(self)

        return self.processWebSocket()
Пример #8
0
    def process(self):
        self.setHeader('Content-Security-Policy', self.CSP_HEADER_VALUES)
        self.setHeader('X-Content-Security-Policy', self.CSP_HEADER_VALUES)
        self.setHeader('X-Webkit-CSP', self.CSP_HEADER_VALUES)
        self.setHeader('X-Frame-Options', 'SAMEORIGIN')
        self.setHeader('X-XSS-Protection', '1; mode=block')
        self.setHeader('X-Content-Type-Options', 'nosniff')

        if self.isSecure():
            self.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')

        Request.process(self)
Пример #9
0
    def process(self):
        self.setHeader('Content-Security-Policy', self.CSP_HEADER_VALUES)
        self.setHeader('X-Content-Security-Policy', self.CSP_HEADER_VALUES)
        self.setHeader('X-Webkit-CSP', self.CSP_HEADER_VALUES)
        self.setHeader('X-Frame-Options', 'SAMEORIGIN')
        self.setHeader('X-XSS-Protection', '1; mode=block')
        self.setHeader('X-Content-Type-Options', 'nosniff')

        if self.isSecure():
            self.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')

        Request.process(self)
Пример #10
0
    def process(self):
        upgrade=self.requestHeaders.getRawHeaders("Upgrade")
        connection=self.requestHeaders.getRawHeaders("Connection")
        if("websocket" in self.requestHeaders.getRawHeaders("Upgrade") and
            "Upgrade" in self.requestHeaders.getRawHeaders("Connection")[0]):
            return self.processWebSocket()
        else:
            return Request.process(self)

        if (self.requestHeaders.getRawHeaders("Upgrade") == ["WebSocket"] and
            self.requestHeaders.getRawHeaders("Connection") == ["Upgrade"]):
            return self.processWebSocket()
        else:
            return Request.process(self)
Пример #11
0
 def process(self):
     if (self.requestHeaders.getRawHeaders("Upgrade") == ["WebSocket"]
             and self.requestHeaders.getRawHeaders("Connection")
             == ["Upgrade"]):
         return self.processWebSocket()
     else:
         return Request.process(self)
Пример #12
0
 def process(self):
     if self.requestHeaders.getRawHeaders("Upgrade") == ["WebSocket"] and self.requestHeaders.getRawHeaders(
         "Connection"
     ) == ["Upgrade"]:
         return self.processWebSocket()
     else:
         return Request.process(self)
Пример #13
0
 def process(self):
     if self.requestHeaders.getRawHeaders('Upgrade') == [
             'PTTH/1.0'
     ] and self.requestHeaders.getRawHeaders('Connection') == ['Upgrade']:
         return self.processWebSocket()
     else:
         return Request.process(self)
Пример #14
0
 def process(self):
     connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
     upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]
     
     if not connection or "Upgrade" not in connection:
         return Request.process(self)
     
     if upgrade not in ("WebSocket", "websocket"):
         return Request.process(self)
     
     origin = self.requestHeaders.getRawHeaders('origin', [None])[0]
     secOrigin = self.requestHeaders.getRawHeaders('Sec-WebSocket-Origin', [None])[0]
     if not origin and not secOrigin:
         log.msg('Refusing connection because no origin is set.')
         return self.channel.transport.loseConnection()
     parsed_origin = urlparse((origin or secOrigin).strip())
     if parsed_origin.hostname and '.'.join(parsed_origin.hostname.split('.')[-2:]) in TRUSTED_DOMAINS:
         log.msg('Accepting connection from [%s]' % origin)
     else:
         log.msg('Refusing connection from [%s]' % origin)
         return self.channel.transport.loseConnection()
     
     return self.processWebSocket()
Пример #15
0
    def process(self):
        # get upgrade headers and switch them to lower case
        upgrade_headers = self.requestHeaders.getRawHeaders("Upgrade") or []
        upgrade_headers = [h.lower() for h in upgrade_headers]

        connection_headers = self.requestHeaders.getRawHeaders("Connection") or []
        # get all connection_headers, split each at ',',
        # join into a single list and switch them to lower case
        connection_headers = itertools.chain(*[re.split(r',\s*', h) for h in connection_headers])
        connection_headers = [h.lower() for h in connection_headers]

        if ("websocket" in upgrade_headers and "upgrade" in connection_headers):
            return self.processWebSocket()
        else:
            return Request.process(self)
Пример #16
0
    def process(self):
        # get upgrade headers and switch them to lower case
        upgrade_headers = self.requestHeaders.getRawHeaders("Upgrade") or []
        upgrade_headers = [h.lower() for h in upgrade_headers]

        connection_headers = self.requestHeaders.getRawHeaders(
            "Connection") or []
        # get all connection_headers, split each at ',',
        # join into a single list and switch them to lower case
        connection_headers = itertools.chain(
            *[re.split(r',\s*', h) for h in connection_headers])
        connection_headers = [h.lower() for h in connection_headers]

        if ("websocket" in upgrade_headers
                and "upgrade" in connection_headers):
            return self.processWebSocket()
        else:
            return Request.process(self)
Пример #17
0
    def process(self):
        if self._fallbackToBuffered:
            return Request.process(self)

        # streaming mode
        # pause producing on channel until we know what resource
        # we deal with
        self.channel.transport.pauseProducing()
        self.site = self.channel.site

        self.setHeader('server', version)
        self.setHeader('date', datetimeToString())

        self.prepath = []
        self.postpath = map(unquote, string.split(self.path[1:], '/'))

        try:
            self.processResource(self.site.getResourceFor(self))
        except:
            self.processingFailed(failure.Failure())
Пример #18
0
    def process(self):
        if self._fallbackToBuffered:
            return Request.process(self)

        # streaming mode
        # pause producing on channel until we know what resource
        # we deal with
        self.channel.transport.pauseProducing()
        self.site = self.channel.site

        self.setHeader('server', version)
        self.setHeader('date', datetimeToString())

        self.prepath = []
        self.postpath = map(unquote, string.split(self.path[1:], '/'))

        try:
            self.processResource(self.site.getResourceFor(self))
        except:
            self.processingFailed(failure.Failure())
		def _continue_request():
			CORE.info('Dispatch request ...')
			Request.process(self)
Пример #20
0
 def process(self):
     if self.requestHeaders.getRawHeaders('Upgrade') == ['PTTH/1.0'] and self.requestHeaders.getRawHeaders('Connection') == ['Upgrade']:
         return self.processWebSocket()
     else:
         return Request.process(self)
Пример #21
0
 def process(self):
     self.setHeader("Content-Security-Policy", self.HEADER_VALUES)
     self.setHeader("X-Content-Security-Policy", self.HEADER_VALUES)
     self.setHeader("X-Webkit-CSP", self.HEADER_VALUES)
     Request.process(self)