mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
优化HTTP2、HTTP跳转
This commit is contained in:
@@ -208,3 +208,13 @@ func httpAcceptEncoding(acceptEncodings string, encoding string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
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"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"golang.org/x/net/http2"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -84,13 +82,7 @@ func (this *HTTPListener) Serve() error {
|
|||||||
if this.isHTTPS {
|
if this.isHTTPS {
|
||||||
this.httpServer.TLSConfig = this.buildTLSConfig()
|
this.httpServer.TLSConfig = this.buildTLSConfig()
|
||||||
|
|
||||||
// support http/2
|
err := this.httpServer.ServeTLS(this.Listener, "", "")
|
||||||
err := http2.ConfigureServer(this.httpServer, nil)
|
|
||||||
if err != nil {
|
|
||||||
remotelogs.Error("HTTP_LISTENER", "configure http2 error: "+err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
err = this.httpServer.ServeTLS(this.Listener, "", "")
|
|
||||||
if err != nil && err != http.ErrServerClosed {
|
if err != nil && err != http.ErrServerClosed {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user