mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
Fix HTTP serialization
This commit is contained in:
parent
3d2431d21c
commit
b0d009664a
@ -138,7 +138,7 @@ type HttpAuthenticator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this HttpAuthenticator) GetClientWriter() *HeaderWriter {
|
func (this HttpAuthenticator) GetClientWriter() *HeaderWriter {
|
||||||
header := alloc.NewLocalBuffer(2048)
|
header := alloc.NewLocalBuffer(2048).Clear()
|
||||||
config := this.config.Request
|
config := this.config.Request
|
||||||
header.AppendString(config.Method.GetValue()).AppendString(" ").AppendString(config.PickUri()).AppendString(" ").AppendString(config.GetFullVersion()).AppendString(CRLF)
|
header.AppendString(config.Method.GetValue()).AppendString(" ").AppendString(config.PickUri()).AppendString(" ").AppendString(config.GetFullVersion()).AppendString(CRLF)
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ func (this HttpAuthenticator) GetClientWriter() *HeaderWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this HttpAuthenticator) GetServerWriter() *HeaderWriter {
|
func (this HttpAuthenticator) GetServerWriter() *HeaderWriter {
|
||||||
header := alloc.NewLocalBuffer(2048)
|
header := alloc.NewLocalBuffer(2048).Clear()
|
||||||
config := this.config.Response
|
config := this.config.Response
|
||||||
header.AppendString(config.GetFullVersion()).AppendString(" ").AppendString(config.Status.GetCode()).AppendString(" ").AppendString(config.Status.GetReason()).AppendString(CRLF)
|
header.AppendString(config.GetFullVersion()).AppendString(" ").AppendString(config.Status.GetCode()).AppendString(" ").AppendString(config.Status.GetReason()).AppendString(CRLF)
|
||||||
|
|
||||||
|
@ -21,3 +21,26 @@ func TestReaderWriter(t *testing.T) {
|
|||||||
assert.Error(err).IsNil()
|
assert.Error(err).IsNil()
|
||||||
assert.Bytes(buffer.Value).Equals([]byte{'e', 'f', 'g'})
|
assert.Bytes(buffer.Value).Equals([]byte{'e', 'f', 'g'})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRequestHeader(t *testing.T) {
|
||||||
|
assert := assert.On(t)
|
||||||
|
|
||||||
|
factory := HttpAuthenticatorFactory{}
|
||||||
|
auth := factory.Create(&Config{
|
||||||
|
Request: &RequestConfig{
|
||||||
|
Uri: []string{"/"},
|
||||||
|
Header: []*Header{
|
||||||
|
{
|
||||||
|
Name: "Test",
|
||||||
|
Value: []string{"Value"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).(HttpAuthenticator)
|
||||||
|
|
||||||
|
cache := alloc.NewBuffer().Clear()
|
||||||
|
err := auth.GetClientWriter().Write(cache)
|
||||||
|
assert.Error(err).IsNil()
|
||||||
|
|
||||||
|
assert.String(cache.String()).Equals("GET / HTTP/1.1\r\nTest: Value\r\n\r\n")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user