 Matthew Holt
					
					5 years ago
						Matthew Holt
					
					5 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 2A349DD577D586A5
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
14 additions and 
0 deletions
			 
			
		 
		
			
				- 
					
					
					 
					modules/caddyhttp/matchers.go
				
- 
					
					
					 
					modules/caddyhttp/matchers_test.go
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -445,6 +445,10 @@ func matchHeaders(input, against http.Header, host string) bool { | 
			
		
	
		
			
				
					|  |  |  | 			// match if the header field exists at all
 | 
			
		
	
		
			
				
					|  |  |  | 			continue | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		if allowedFieldVals == nil && actualFieldVals == nil { | 
			
		
	
		
			
				
					|  |  |  | 			// a nil list means match if the header does not exist at all
 | 
			
		
	
		
			
				
					|  |  |  | 			continue | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		var match bool | 
			
		
	
		
			
				
					|  |  |  | 	fieldVals: | 
			
		
	
		
			
				
					|  |  |  | 		for _, actualFieldVal := range actualFieldVals { | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -480,6 +480,16 @@ func TestHeaderMatcher(t *testing.T) { | 
			
		
	
		
			
				
					|  |  |  | 			host:   "caddyserver.com", | 
			
		
	
		
			
				
					|  |  |  | 			expect: false, | 
			
		
	
		
			
				
					|  |  |  | 		}, | 
			
		
	
		
			
				
					|  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  | 			match:  MatchHeader{"Must-Not-Exist": nil}, | 
			
		
	
		
			
				
					|  |  |  | 			input:  http.Header{}, | 
			
		
	
		
			
				
					|  |  |  | 			expect: true, | 
			
		
	
		
			
				
					|  |  |  | 		}, | 
			
		
	
		
			
				
					|  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  | 			match:  MatchHeader{"Must-Not-Exist": nil}, | 
			
		
	
		
			
				
					|  |  |  | 			input:  http.Header{"Must-Not-Exist": []string{"do not match"}}, | 
			
		
	
		
			
				
					|  |  |  | 			expect: false, | 
			
		
	
		
			
				
					|  |  |  | 		}, | 
			
		
	
		
			
				
					|  |  |  | 	} { | 
			
		
	
		
			
				
					|  |  |  | 		req := &http.Request{Header: tc.input, Host: tc.host} | 
			
		
	
		
			
				
					|  |  |  | 		actual := tc.match.Match(req) | 
			
		
	
	
		
			
				
					|  |  | 
 |