How to use the aquests.protocols.http.response.FailedResponse function in aquests

To help you get started, we’ve selected a few aquests 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 / http / request_handler.py View on Github external
self.buffer = b""
				
				if chunked_size == 0:
					self.end_of_data = True
					self.asyncon.set_terminator (b"\r\n")
					
				elif chunked_size > 0:
					self.asyncon.set_terminator (chunked_size)
			
			else:
				self.found_end_of_body ()
						
		else:
			self.expect_disconnect = False
			self.create_response ()
			if not self.response or isinstance (self.response, http_response.FailedResponse):
				return
			
			if self.used_chunk ():
				self.wrap_in_chunk = True
				self.asyncon.set_terminator (b"\r\n") #chunked transfer
			
			else:
				clen = 0 # no transfer-encoding, no content-lenth	
				try:
					clen = self.get_content_length ()
				except TypeError:
					if self.will_be_close ():
						self.expect_disconnect = True
						if self.response.get_header ("content-type"):
							clen = None						
				if clen == 0:
github hansroh / aquests / aquests / protocols / http / request_handler.py View on Github external
def connection_closed (self, why, msg):		
		if not self.asyncon:
			return # server side disconnecting because timeout, ignored
		# possibly disconnected cause of keep-alive timeout
		# but works only HTTP 1.1
		if not self.http2_handler and why == 700 and self.response is None and self.retry_count == 0:
			self.retry_count = 1			
			self.handle_rerequest ()
			return True		

		if self.response and (self.expect_disconnect or why >= 700):
			self.close_case ()
			return

		self.response = http_response.FailedResponse (why, msg, self.request)
		if hasattr (self.asyncon, "begin_tran"):
			self.close_case ()