mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	HTTP Header中支持设置非标Header
This commit is contained in:
		@@ -1650,6 +1650,20 @@ func (this *HTTPRequest) processRequestHeaders(reqHeader http.Header) {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 非标Header
 | 
				
			||||||
 | 
							if len(this.web.RequestHeaderPolicy.NonStandardHeaders) > 0 {
 | 
				
			||||||
 | 
								for _, name := range this.web.RequestHeaderPolicy.NonStandardHeaders {
 | 
				
			||||||
 | 
									var canonicalKey = http.CanonicalHeaderKey(name)
 | 
				
			||||||
 | 
									if canonicalKey != name {
 | 
				
			||||||
 | 
										v, ok := reqHeader[canonicalKey]
 | 
				
			||||||
 | 
										if ok {
 | 
				
			||||||
 | 
											delete(reqHeader, canonicalKey)
 | 
				
			||||||
 | 
											reqHeader[name] = v
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1749,6 +1763,20 @@ func (this *HTTPRequest) processResponseHeaders(responseHeader http.Header, stat
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 非标Header
 | 
				
			||||||
 | 
							if len(this.web.ResponseHeaderPolicy.NonStandardHeaders) > 0 {
 | 
				
			||||||
 | 
								for _, name := range this.web.ResponseHeaderPolicy.NonStandardHeaders {
 | 
				
			||||||
 | 
									var canonicalKey = http.CanonicalHeaderKey(name)
 | 
				
			||||||
 | 
									if canonicalKey != name {
 | 
				
			||||||
 | 
										v, ok := responseHeader[canonicalKey]
 | 
				
			||||||
 | 
										if ok {
 | 
				
			||||||
 | 
											delete(responseHeader, canonicalKey)
 | 
				
			||||||
 | 
											responseHeader[name] = v
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// CORS
 | 
							// CORS
 | 
				
			||||||
		if this.web.ResponseHeaderPolicy.CORS != nil && this.web.ResponseHeaderPolicy.CORS.IsOn && (!this.web.ResponseHeaderPolicy.CORS.OptionsMethodOnly || this.RawReq.Method == http.MethodOptions) {
 | 
							if this.web.ResponseHeaderPolicy.CORS != nil && this.web.ResponseHeaderPolicy.CORS.IsOn && (!this.web.ResponseHeaderPolicy.CORS.OptionsMethodOnly || this.RawReq.Method == http.MethodOptions) {
 | 
				
			||||||
			var corsConfig = this.web.ResponseHeaderPolicy.CORS
 | 
								var corsConfig = this.web.ResponseHeaderPolicy.CORS
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user