def do_collect(self, stream, request): ''' Invoked on GET /speedtest/collect ''' stream.response_rewriter = self._rewrite_response request.uri = '/collect/speedtest' xmlreq = marshal.unmarshal_object(request.body.read(), 'application/xml', SpeedtestCollect) message = { 'uuid': xmlreq.client, 'timestamp': int(float(xmlreq.timestamp)), # old clients bug 'internal_address': xmlreq.internalAddress, 'real_address': xmlreq.realAddress, 'remote_address': xmlreq.remoteAddress, 'connect_time': xmlreq.connectTime, 'latency': xmlreq.latency, 'download_speed': xmlreq.downloadSpeed, 'upload_speed': xmlreq.uploadSpeed, 'privacy_informed': xmlreq.privacy_informed, 'privacy_can_collect': xmlreq.privacy_can_collect, 'privacy_can_share': xmlreq.privacy_can_share, 'platform': xmlreq.platform, 'neubot_version': xmlreq.neubot_version, } # XXX Here we don't rewrite content-length which becomes bogus request['content-type'] = 'application/json' request.body = StringIO.StringIO(json.dumps(message)) NEGOTIATE_SERVER.process_request(stream, request)
def do_negotiate(self, stream, request): ''' Invoked on GET /speedtest/negotiate ''' stream.response_rewriter = self._rewrite_response # # Use POST because the semantic is that the body has no # meaning, when the request method is GET. # request.method = 'POST' request.uri = '/negotiate/speedtest' request.body = StringIO.StringIO('{}') NEGOTIATE_SERVER.process_request(stream, request)
def run(poller, conf): ''' Start the negotiate server ''' NEGOTIATE_SERVER.register_module('speedtest', NEGOTIATE_SERVER_SPEEDTEST) NEGOTIATE_SERVER.register_module('bittorrent', NEGOTIATE_SERVER_BITTORRENT) HTTP_SERVER.register_child(NEGOTIATE_SERVER, '/negotiate/') HTTP_SERVER.register_child(NEGOTIATE_SERVER, '/collect/') CONFIG.register_descriptions({ 'negotiate.parallelism': 'Number of parallel tests', 'negotiate.min_thresh': 'Minimum trehshold for RED', 'negotiate.max_thresh': 'Maximum trehshold for RED', })
def run(poller, conf): """ Start the negotiate server """ NEGOTIATE_SERVER.register_module("speedtest", NEGOTIATE_SERVER_SPEEDTEST) NEGOTIATE_SERVER.register_module("bittorrent", NEGOTIATE_SERVER_BITTORRENT) NEGOTIATE_SERVER.register_module("raw", NEGOTIATE_SERVER_RAW) NEGOTIATE_SERVER.register_module("skype", NEGOTIATE_SERVER_SKYPE) HTTP_SERVER.register_child(NEGOTIATE_SERVER, "/negotiate/") HTTP_SERVER.register_child(NEGOTIATE_SERVER, "/collect/") CONFIG.register_descriptions( { "negotiate.parallelism": "Number of parallel tests", "negotiate.min_thresh": "Minimum trehshold for RED", "negotiate.max_thresh": "Maximum trehshold for RED", } )
def test_huge(self): ''' Make sure we don't accept big requests ''' message = Message() message['Content-Length'] = str(1048576 + 1) self.assertFalse(NEGOTIATE_SERVER.got_request_headers(None, message))
def test_chunked(self): ''' Make sure we don't accept chunked requests ''' message = Message() message['Transfer-Encoding'] = 'chunked' self.assertFalse(NEGOTIATE_SERVER.got_request_headers(None, message))
def do_negotiate(self, stream, request): ''' Invoked on GET /speedtest/negotiate ''' stream.response_rewriter = self._rewrite_response request.uri = '/negotiate/speedtest' request.body = StringIO.StringIO('{}') NEGOTIATE_SERVER.process_request(stream, request)