1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
15 type shutdownCodec
struct {
20 func (c
*shutdownCodec
) WriteRequest(*Request
, any
) error
{ return nil }
21 func (c
*shutdownCodec
) ReadResponseBody(any
) error
{ return nil }
22 func (c
*shutdownCodec
) ReadResponseHeader(*Response
) error
{
24 return errors
.New("shutdownCodec ReadResponseHeader")
26 func (c
*shutdownCodec
) Close() error
{
31 func TestCloseCodec(t
*testing
.T
) {
32 codec
:= &shutdownCodec
{responded
: make(chan int)}
33 client
:= NewClientWithCodec(codec
)
37 t
.Error("client.Close did not close codec")
41 // Test that errors in gob shut down the connection. Issue 7689.
44 msg
[]byte // Not exported, so R does not work with gob.
49 func (s
*S
) Recv(nul
*struct{}, reply
*R
) error
{
50 *reply
= R
{[]byte("foo")}
54 func TestGobError(t
*testing
.T
) {
60 if !strings
.Contains(err
.(error
).Error(), "reading body unexpected EOF") {
61 t
.Fatal("expected `reading body unexpected EOF', got", err
)
66 listen
, err
:= net
.Listen("tcp", "127.0.0.1:0")
72 client
, err
:= Dial("tcp", listen
.Addr().String())
78 err
= client
.Call("S.Recv", &struct{}{}, &reply
)
83 fmt
.Printf("%#v\n", reply
)