How to use the rs4.producers.simple_producer function in rs4

To help you get started, we’ve selected a few rs4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hansroh / aquests / aquests / protocols / smtp / async_smtp.py View on Github external
self.__stat = 9
				self.push ("rset")
				return
			self.__stat = 6
			self.push ("data")
		
		elif self.__stat == 6:
			if code != 354:
				self.__code, self.__resp = code, resp
				self.__stat = 9
				self.push ("rset")
				return
			self.__stat = 9
			
			q = quotedata (self.composer.get_DATA ()) + ".\r\n"
			self.push_with_producer (producers.simple_producer (q.encode ("utf8")))
			#self.push (q.encode ("utf8"))
			self.__sent = len (q)
				
		elif self.__stat == 9:
			if self.__sent and code == 250:
				self.__code, self.__resp = -250, "OK"
			elif self.__sent:
				self.__code, self.__resp = code, resp								
			self.__stat = 10
			self.push ("quit")
			
		else:			
			self.handle_close ()
github hansroh / aquests / aquests / protocols / http2 / request_handler.py View on Github external
def handle_request (self, handler):
		self.request = handler.request
		stream_id = self.get_new_stream_id ()		
		self.add_request (stream_id, handler)		
		self.asyncon.set_active (False)		
		
		headers, content_encoded = handler.get_request_header ("2.0", False)
		payload = handler.get_request_payload ()
		producer = None
		if payload:
			if type (payload) is bytes:
				producer = producers.globbing_producer (
					producers.simple_producer (payload)
				)
			else:
				# multipart, grpc_producer 
				producer = producers.globbing_producer (payload)
		
		header = h2header_producer (stream_id, headers, producer, self.conn, self._clock)		
		self.asyncon.push (header)		
		if producer:
			payload = h2frame_producer (stream_id, 0, 1, producer, self.conn, self._clock)
			# is it proper?
			#payload = producers.ready_globbing_producer (payload)
			self.asyncon.push (payload)