def header(self): b64 = b64encode(('%s:%s' % ( self.username, self.password)).encode(DEFAULT_CHARSET)) return 'Basic %s' % native_str(b64.strip(), DEFAULT_CHARSET)
def challenge_response(self, key): sha1 = hashlib.sha1(to_bytes(key+WEBSOCKET_GUID)) return native_str(base64.b64encode(sha1.digest()))
def test_native_str(self): s = 'ciao' s2 = httpurl.native_str(s) self.assertEqual(id(s), id(s2))