mirror of
				https://github.com/django/daphne.git
				synced 2025-10-29 06:47:32 +03:00 
			
		
		
		
	decode incoming data before loading
This commit is contained in:
		
							parent
							
								
									454839dafa
								
							
						
					
					
						commit
						c1990a92ed
					
				|  | @ -27,6 +27,10 @@ class RedisChannelBackend(BaseChannelBackend): | |||
|         return redis.Redis(host=self.host, port=self.port) | ||||
| 
 | ||||
|     def send(self, channel, message): | ||||
|         # if channel is no str (=> bytes) convert it | ||||
|         if not isinstance(channel, str): | ||||
|             channel = channel.decode('utf-8') | ||||
| 
 | ||||
|         # Write out message into expiring key (avoids big items in list) | ||||
|         key = self.prefix + uuid.uuid4().get_hex() | ||||
|         self.connection.set( | ||||
|  | @ -59,7 +63,7 @@ class RedisChannelBackend(BaseChannelBackend): | |||
|                 content = self.connection.get(result[1]) | ||||
|                 if content is None: | ||||
|                     continue | ||||
|                 return result[0][len(self.prefix):], json.loads(content) | ||||
|                 return result[0][len(self.prefix):].decode("utf-8"), json.loads(content.decode("utf-8")) | ||||
|             else: | ||||
|                 return None, None | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user