mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-22 01:06:30 -05:00
refactor trojan WriteHeader function.
This commit is contained in:
parent
72475c2924
commit
680d5bb2ac
@ -37,7 +37,7 @@ type ConnWriter struct {
|
|||||||
// Write implements io.Writer
|
// Write implements io.Writer
|
||||||
func (c *ConnWriter) Write(p []byte) (n int, err error) {
|
func (c *ConnWriter) Write(p []byte) (n int, err error) {
|
||||||
if !c.headerSent {
|
if !c.headerSent {
|
||||||
if err := c.WriteHeader(); err != nil {
|
if err := c.writeHeader(); err != nil {
|
||||||
return 0, newError("failed to write request header").Base(err)
|
return 0, newError("failed to write request header").Base(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,6 +61,15 @@ func (c *ConnWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConnWriter) WriteHeader() error {
|
func (c *ConnWriter) WriteHeader() error {
|
||||||
|
if !c.headerSent {
|
||||||
|
if err := c.writeHeader(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ConnWriter) writeHeader() error {
|
||||||
buffer := buf.StackNew()
|
buffer := buf.StackNew()
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user