mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	rewrite for efficiency
This commit is contained in:
		
							parent
							
								
									f617b27110
								
							
						
					
					
						commit
						016ae3b9e9
					
				
					 2 changed files with 9 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -219,9 +219,11 @@ namespace proxy {
 | 
			
		|||
		/* replace headers */
 | 
			
		||||
		req.UpdateHeader("User-Agent", "MYOB/6.66 (AN/ON)");
 | 
			
		||||
		/* add headers */
 | 
			
		||||
		/* close connection, if not Connection: (U|u)pgrade (for websocket) */
 | 
			
		||||
		auto h = req.GetHeader ("Connection");
 | 
			
		||||
		if (h.find("upgrade") == std::string::npos && h.find("Upgrade") == std::string::npos)
 | 
			
		||||
			req.UpdateHeader("Connection", "close"); /* close everything, except websocket */
 | 
			
		||||
		auto x = h.find("pgrade"); 
 | 
			
		||||
		if (!(x != std::string::npos && std::tolower(h[x - 1]) == 'u'))
 | 
			
		||||
			req.UpdateHeader("Connection", "close");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -256,10 +256,12 @@ namespace client
 | 
			
		|||
					{
 | 
			
		||||
						if (!m_ConnectionSent && !line.compare(0, 10, "Connection"))
 | 
			
		||||
						{
 | 
			
		||||
							if (line.find("upgrade") == std::string::npos && line.find("Upgrade") == std::string::npos)
 | 
			
		||||
								m_OutHeader << "Connection: close\r\n"; /* close everything, except websocket */
 | 
			
		||||
							else
 | 
			
		||||
							/* close connection, if not Connection: (U|u)pgrade (for websocket) */
 | 
			
		||||
							auto x = line.find("pgrade"); 
 | 
			
		||||
							if (x != std::string::npos && std::tolower(line[x - 1]) == 'u')
 | 
			
		||||
								m_OutHeader << line << "\r\n";
 | 
			
		||||
							else
 | 
			
		||||
								m_OutHeader << "Connection: close\r\n";
 | 
			
		||||
 | 
			
		||||
							m_ConnectionSent = true;
 | 
			
		||||
						}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue