def http_consumer(message): # Make standard HTTP response - access ASGI path attribute directly response = HttpResponse("Hello world! You asked for %s" % message.content['path']) # Encode that response into message format (ASGI) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): print('http:---->') response = HttpResponse(pp.pformat(message.content), content_type='text/plain') for chunk in AsgiHandler.encode_response(response): logger.debug(chunk) message.reply_channel.send(chunk)
def http_consumer(message): """A consumer that intercepts a http request""" response = HttpResponse("Hello world! You asked for %s" % message.content['path']) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): print("http_consumer") # Make standard HTTP response - access ASGI path attribute directly response = HttpResponse("Hello world! You asked for %s" % message.content['path']) # Encode that response into message format (ASGI) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): print "HTTP request %s" % message.content['path'] log_send("HTTP request %s" % message.content['path']) Group("log").send({"text":json.dumps({'text':"HTTP Connect!"})}) response = HttpResponse("Channels %s" % message.content['path']) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): # Make standard HTTP response - access ASGI path attribute directly from django.http import HttpResponse response = HttpResponse("Hello world! You asked for %s" % message.content['path']) # Encode that response into message format (ASGI) from channels.handler import AsgiHandler for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def my_consumer(message): print(('yesdss' + message.handle)) # response = HttpResponse("Hello world! You asked for %s" % message.content['path']) django_request = AsgiRequest(message) # Run view response = HttpResponse("Hello world! You asked for %s" % message.content['path']) # Encode that response into message format (ASGI) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): #channel_session_user = True #http_user = True # Decode the request from message format to a Request object django_request = AsgiRequest(message) # Run view django_response = entities(django_request) # Encode the response into message format for chunk in AsgiHandler.encode_response(django_response): message.reply_channel.send(chunk)
def http_handler(self, message, **kwargs): """ Called on HTTP request :param message: message received :return: """ # Get Django HttpRequest object from ASGI Message request = AsgiRequest(message) # CORS response = CorsMiddleware().process_request(request) if not isinstance(response, HttpResponse): # Try to process content try: if request.method != 'POST': raise MethodNotSupported('Only POST method is supported') content = request.body.decode('utf-8') except (UnicodeDecodeError, MethodNotSupported): content = '' result, is_notification = self.__handle(content, message, kwargs) # Set response status code # http://www.jsonrpc.org/historical/json-rpc-over-http.html#response-codes if not is_notification: # call response status_code = 200 if 'error' in result: code = result['error']['code'] status_code = self._http_codes[ code] if code in self._http_codes else 500 else: # notification response status_code = 204 if result and 'error' in result: code = result['error']['code'] status_code = self._http_codes[ code] if code in self._http_codes else 500 result = '' response = HttpResponse(self.__class__._encode(result), content_type='application/json-rpc', status=status_code) # CORS response = CorsMiddleware().process_response(request, response) # Encode that response into message format (ASGI) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): response = HttpResponse("hello world! you asked for %s" % message.content['path']) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_comsumer_request(message): response = HttpResponse('Hello world! %s' % message.content['path']) for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def relase(request): response = HttpResponse('ok') for chunk in AsgiHandler.encode_response(response): Group('w8').send(chunk)
def http_request(message): response = HttpResponse("Hello world from a consumer!") for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): response = HttpResponse( 'Welcome to Game of Life! You should try websockets.') for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)
def http_consumer(message): response = HttpResponse("Hello world! You asked for {}" .format(message.content['path'])) for chunk in AsgiHandler.encode_response(response): message.reply_chanel.send(chunk)
def http_consumer(message): response = render_to_response('index.html') for chunk in AsgiHandler.encode_response(response): message.reply_channel.send(chunk)