Pārlūkot izejas kodu

update http header

Darien Raymond 9 gadi atpakaļ
vecāks
revīzija
66e8090d3a

+ 4 - 0
tools/conf/transport_authenticators.go

@@ -56,6 +56,10 @@ func (this *HTTPAuthenticatorRequest) Build() (*http.RequestConfig, error) {
 					"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46",
 				},
 			},
+			{
+				Name:  "Accept-Encoding",
+				Value: []string{"gzip, deflate"},
+			},
 		},
 	}
 

+ 11 - 0
transport/internet/authenticators/http/config.go

@@ -1,6 +1,7 @@
 package http
 
 import (
+	"strings"
 	"v2ray.com/core/common/dice"
 )
 
@@ -62,6 +63,16 @@ func (this *RequestConfig) GetFullVersion() string {
 	return "HTTP/" + this.Version.GetValue()
 }
 
+func (this *ResponseConfig) HasHeader(header string) bool {
+	cHeader := strings.ToLower(header)
+	for _, tHeader := range this.Header {
+		if strings.ToLower(tHeader.Name) == cHeader {
+			return true
+		}
+	}
+	return false
+}
+
 func (this *ResponseConfig) PickHeaders() []string {
 	n := len(this.Header)
 	if n == 0 {

+ 5 - 0
transport/internet/authenticators/http/http.go

@@ -4,6 +4,8 @@ import (
 	"bytes"
 	"io"
 	"net"
+	"net/http"
+	"time"
 
 	"v2ray.com/core/common/alloc"
 	"v2ray.com/core/common/loader"
@@ -159,6 +161,9 @@ func (this HttpAuthenticator) GetServerWriter() *HeaderWriter {
 	for _, h := range headers {
 		header.AppendString(h).AppendString(CRLF)
 	}
+	if !config.HasHeader("Date") {
+		header.AppendString("Date: ").AppendString(time.Now().Format(http.TimeFormat)).AppendString(CRLF)
+	}
 	header.AppendString(CRLF)
 	return &HeaderWriter{
 		header: header,