Skip to content

Commit 8f48754

Browse files
committed
Merge pull request #11 from google/consistency
Consistency
2 parents 1626c34 + 2c9e40c commit 8f48754

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed
File renamed without changes.
File renamed without changes.

header/header_modifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestModifyRequestWithHostHeader(t *testing.T) {
6666
func TestModifierFromJSON(t *testing.T) {
6767
msg := []byte(`{
6868
"header.Modifier": {
69-
"type": ["request", "response"],
69+
"scope": ["request", "response"],
7070
"name": "X-Martian",
7171
"value": "true"
7272
}

martianurl/url_modifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type modifierJSON struct {
4040
}
4141

4242
func init() {
43-
parse.Register("martianurl.Modifier", modifierFromJSON)
43+
parse.Register("url.Modifier", modifierFromJSON)
4444
}
4545

4646
// ModifyRequest sets the fields of req.URL to m.Url if they are not the zero value.

martianurl/url_modifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestIntegration(t *testing.T) {
116116

117117
func TestModifierFromJSON(t *testing.T) {
118118
msg := []byte(`{
119-
"martianurl.Modifier": {
119+
"url.Modifier": {
120120
"scope": ["request"],
121121
"scheme": "https",
122122
"host": "www.martian.proxy",

martianurl/url_verifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
)
3333

3434
func init() {
35-
parse.Register("martianurl.Verifier", verifierFromJSON)
35+
parse.Register("url.Verifier", verifierFromJSON)
3636
}
3737

3838
// Verifier verifies the structure of URLs.

martianurl/url_verifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestVerifyRequests(t *testing.T) {
118118

119119
func TestVerifierFromJSON(t *testing.T) {
120120
msg := []byte(`{
121-
"martianurl.Verifier": {
121+
"url.Verifier": {
122122
"scope": ["request"],
123123
"scheme": "https",
124124
"host": "www.martian.proxy",

proxy_test.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,20 @@ func (p *timeoutPipe) SetWriteDeadline(t time.Time) error {
159159
return nil
160160
}
161161

162-
func (p *timeoutPipe) Read(b []byte) (n int, err error) {
163-
rc := make(chan bool, 1)
162+
func (p *timeoutPipe) Read(b []byte) (int, error) {
163+
type connRead struct {
164+
n int
165+
err error
166+
}
167+
168+
rc := make(chan connRead, 1)
164169

165170
go func() {
166-
n, err = p.Conn.Read(b)
167-
rc <- true
171+
n, err := p.Conn.Read(b)
172+
rc <- connRead{
173+
n: n,
174+
err: err,
175+
}
168176
}()
169177

170178
d := p.readTimeout.Sub(time.Now())
@@ -173,19 +181,26 @@ func (p *timeoutPipe) Read(b []byte) (n int, err error) {
173181
}
174182

175183
select {
176-
case <-rc:
177-
return n, err
184+
case cr := <-rc:
185+
return cr.n, cr.err
178186
case <-time.After(d):
179187
return 0, &pipeNetError{true, false}
180188
}
181189
}
182190

183191
func (p *timeoutPipe) Write(b []byte) (n int, err error) {
184-
wc := make(chan bool, 1)
192+
type connWrite struct {
193+
n int
194+
err error
195+
}
196+
wc := make(chan connWrite, 1)
185197

186198
go func() {
187-
n, err = p.Conn.Write(b)
188-
wc <- true
199+
n, err := p.Conn.Write(b)
200+
wc <- connWrite{
201+
n: n,
202+
err: err,
203+
}
189204
}()
190205

191206
d := p.writeTimeout.Sub(time.Now())
@@ -194,8 +209,8 @@ func (p *timeoutPipe) Write(b []byte) (n int, err error) {
194209
}
195210

196211
select {
197-
case <-wc:
198-
return n, err
212+
case cw := <-wc:
213+
return cw.n, cw.err
199214
case <-time.After(d):
200215
return 0, &pipeNetError{true, false}
201216
}

0 commit comments

Comments
 (0)