mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	优化HTTP2、HTTP跳转
This commit is contained in:
		@@ -208,3 +208,13 @@ func httpAcceptEncoding(acceptEncodings string, encoding string) bool {
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 跳转到某个URL
 | 
			
		||||
func httpRedirect(writer http.ResponseWriter, req *http.Request, url string, code int) {
 | 
			
		||||
	if len(writer.Header().Get("Content-Type")) == 0 {
 | 
			
		||||
		// 设置Content-Type,是为了让页面不输出链接
 | 
			
		||||
		writer.Header().Set("Content-Type", "text/html; charset=utf-8")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	http.Redirect(writer, req, url, code)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,7 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
 | 
			
		||||
	"github.com/iwind/TeaGo/Tea"
 | 
			
		||||
	"golang.org/x/net/http2"
 | 
			
		||||
	"io"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net"
 | 
			
		||||
@@ -84,13 +82,7 @@ func (this *HTTPListener) Serve() error {
 | 
			
		||||
	if this.isHTTPS {
 | 
			
		||||
		this.httpServer.TLSConfig = this.buildTLSConfig()
 | 
			
		||||
 | 
			
		||||
		// support http/2
 | 
			
		||||
		err := http2.ConfigureServer(this.httpServer, nil)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			remotelogs.Error("HTTP_LISTENER", "configure http2 error: "+err.Error())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		err = this.httpServer.ServeTLS(this.Listener, "", "")
 | 
			
		||||
		err := this.httpServer.ServeTLS(this.Listener, "", "")
 | 
			
		||||
		if err != nil && err != http.ErrServerClosed {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user