This commit is contained in:
WJQSERVER 2024-10-19 16:05:18 +08:00
parent 47d062a1c4
commit c50f23c399
14 changed files with 78 additions and 70 deletions

View file

@ -117,7 +117,6 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
func ProxyRequest(c *gin.Context, u string, cfg *config.Config, mode string) {
method := c.Request.Method
// 记录 IP Method URL UA
logInfo("%s %s %s %s", c.ClientIP(), method, u, c.Request.Header.Get("User-Agent"))
client := createHTTPClient(mode)
@ -150,7 +149,6 @@ func ProxyRequest(c *gin.Context, u string, cfg *config.Config, mode string) {
}
}
// createHTTPClient 创建并配置 HTTP 客户端
func createHTTPClient(mode string) *req.Client {
client := req.C()
switch mode {
@ -220,10 +218,11 @@ func HandleResponseSize(resp *req.Response, cfg *config.Config, c *gin.Context)
}
func CopyResponseHeaders(resp *req.Response, c *gin.Context, cfg *config.Config) {
removeHeaders(resp)
copyHeaders(resp, c)
removeHeaders(resp)
setCORSHeaders(c, cfg)
setDefaultHeaders(c)