1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

update http header

This commit is contained in:
Darien Raymond 2016-11-06 13:38:32 +01:00
parent 805bbe5fe4
commit 66e8090d3a
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 20 additions and 0 deletions

View File

@ -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"},
},
},
}

View File

@ -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 {

View File

@ -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,