diff --git a/auth/auth.go b/auth/auth_filter.go similarity index 100% rename from auth/auth.go rename to auth/auth_filter.go diff --git a/auth/auth_test.go b/auth/auth_filter_test.go similarity index 100% rename from auth/auth_test.go rename to auth/auth_filter_test.go diff --git a/header/header_modifier_test.go b/header/header_modifier_test.go index a802d40d0..8398ad0ec 100644 --- a/header/header_modifier_test.go +++ b/header/header_modifier_test.go @@ -66,7 +66,7 @@ func TestModifyRequestWithHostHeader(t *testing.T) { func TestModifierFromJSON(t *testing.T) { msg := []byte(`{ "header.Modifier": { - "type": ["request", "response"], + "scope": ["request", "response"], "name": "X-Martian", "value": "true" } diff --git a/martianurl/url_modifier.go b/martianurl/url_modifier.go index 4befdcb65..87d3dbd35 100644 --- a/martianurl/url_modifier.go +++ b/martianurl/url_modifier.go @@ -40,7 +40,7 @@ type modifierJSON struct { } func init() { - parse.Register("martianurl.Modifier", modifierFromJSON) + parse.Register("url.Modifier", modifierFromJSON) } // ModifyRequest sets the fields of req.URL to m.Url if they are not the zero value. diff --git a/martianurl/url_modifier_test.go b/martianurl/url_modifier_test.go index 2e572b8f0..2e8f3c224 100644 --- a/martianurl/url_modifier_test.go +++ b/martianurl/url_modifier_test.go @@ -116,7 +116,7 @@ func TestIntegration(t *testing.T) { func TestModifierFromJSON(t *testing.T) { msg := []byte(`{ - "martianurl.Modifier": { + "url.Modifier": { "scope": ["request"], "scheme": "https", "host": "www.martian.proxy", diff --git a/martianurl/url_verifier.go b/martianurl/url_verifier.go index 2abf3b516..8ddcbdd73 100644 --- a/martianurl/url_verifier.go +++ b/martianurl/url_verifier.go @@ -32,7 +32,7 @@ const ( ) func init() { - parse.Register("martianurl.Verifier", verifierFromJSON) + parse.Register("url.Verifier", verifierFromJSON) } // Verifier verifies the structure of URLs. diff --git a/martianurl/url_verifier_test.go b/martianurl/url_verifier_test.go index a87ba47c7..42cd00d43 100644 --- a/martianurl/url_verifier_test.go +++ b/martianurl/url_verifier_test.go @@ -118,7 +118,7 @@ func TestVerifyRequests(t *testing.T) { func TestVerifierFromJSON(t *testing.T) { msg := []byte(`{ - "martianurl.Verifier": { + "url.Verifier": { "scope": ["request"], "scheme": "https", "host": "www.martian.proxy", diff --git a/proxy_test.go b/proxy_test.go index 6627d9007..277ac87a2 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -159,12 +159,20 @@ func (p *timeoutPipe) SetWriteDeadline(t time.Time) error { return nil } -func (p *timeoutPipe) Read(b []byte) (n int, err error) { - rc := make(chan bool, 1) +func (p *timeoutPipe) Read(b []byte) (int, error) { + type connRead struct { + n int + err error + } + + rc := make(chan connRead, 1) go func() { - n, err = p.Conn.Read(b) - rc <- true + n, err := p.Conn.Read(b) + rc <- connRead{ + n: n, + err: err, + } }() d := p.readTimeout.Sub(time.Now()) @@ -173,19 +181,26 @@ func (p *timeoutPipe) Read(b []byte) (n int, err error) { } select { - case <-rc: - return n, err + case cr := <-rc: + return cr.n, cr.err case <-time.After(d): return 0, &pipeNetError{true, false} } } func (p *timeoutPipe) Write(b []byte) (n int, err error) { - wc := make(chan bool, 1) + type connWrite struct { + n int + err error + } + wc := make(chan connWrite, 1) go func() { - n, err = p.Conn.Write(b) - wc <- true + n, err := p.Conn.Write(b) + wc <- connWrite{ + n: n, + err: err, + } }() d := p.writeTimeout.Sub(time.Now()) @@ -194,8 +209,8 @@ func (p *timeoutPipe) Write(b []byte) (n int, err error) { } select { - case <-wc: - return n, err + case cw := <-wc: + return cw.n, cw.err case <-time.After(d): return 0, &pipeNetError{true, false} }