pull/299/merge
Darien Raymond 2017-04-27 11:37:25 +02:00
parent 999717ee28
commit b841042d0c
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 9 additions and 6 deletions

View File

@ -17,7 +17,10 @@ import (
)
const (
CRLF = "\r\n"
// CRLF is the line ending in HTTP header
CRLF = "\r\n"
// ENDING is the double line ending between HTTP header and body.
ENDING = CRLF + CRLF
// max length of HTTP header. Safety precaution for DDoS attack.
@ -39,13 +42,13 @@ type Writer interface {
type NoOpReader struct{}
func (v *NoOpReader) Read(io.Reader) (*buf.Buffer, error) {
func (NoOpReader) Read(io.Reader) (*buf.Buffer, error) {
return nil, nil
}
type NoOpWriter struct{}
func (v *NoOpWriter) Write(io.Writer) error {
func (NoOpWriter) Write(io.Writer) error {
return nil
}
@ -220,16 +223,16 @@ func (a HttpAuthenticator) Client(conn net.Conn) net.Conn {
if a.config.Request == nil && a.config.Response == nil {
return conn
}
var reader Reader = new(NoOpReader)
var reader Reader = NoOpReader{}
if a.config.Request != nil {
reader = new(HeaderReader)
}
var writer Writer = new(NoOpWriter)
var writer Writer = NoOpWriter{}
if a.config.Response != nil {
writer = a.GetClientWriter()
}
return NewHttpConn(conn, reader, writer, new(NoOpWriter))
return NewHttpConn(conn, reader, writer, NoOpWriter{})
}
func (a HttpAuthenticator) Server(conn net.Conn) net.Conn {