From 66e8090d3ab8431712960411fcef799be6d177b8 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 6 Nov 2016 13:38:32 +0100 Subject: [PATCH] update http header --- tools/conf/transport_authenticators.go | 4 ++++ transport/internet/authenticators/http/config.go | 11 +++++++++++ transport/internet/authenticators/http/http.go | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/tools/conf/transport_authenticators.go b/tools/conf/transport_authenticators.go index f1df04d2..c43c1123 100644 --- a/tools/conf/transport_authenticators.go +++ b/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"}, + }, }, } diff --git a/transport/internet/authenticators/http/config.go b/transport/internet/authenticators/http/config.go index 747f3594..953d89a4 100644 --- a/transport/internet/authenticators/http/config.go +++ b/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 { diff --git a/transport/internet/authenticators/http/http.go b/transport/internet/authenticators/http/http.go index 66fdf7ac..482a5d94 100644 --- a/transport/internet/authenticators/http/http.go +++ b/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,