Skip to content

Commit 9f4c5f4

Browse files
committed
Client improvements
1 parent 5f1359b commit 9f4c5f4

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

client.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ func (c *Client) Authenticate() error {
5252
Debug("A: %v %v ", cmr, err)
5353

5454
if err != nil && err.Error() != "EOF" {
55-
c.Close()
5655
Error(ECouldNotReadMIMEHeaders, err)
5756
return err
5857
}
5958

6059
if cmr.Get("Content-Type") != "auth/request" {
61-
c.Close()
6260
Error(EUnexpectedAuthHeader, cmr.Get("Content-Type"))
6361
return fmt.Errorf(EUnexpectedAuthHeader, cmr.Get("Content-Type"))
6462
}
@@ -68,13 +66,11 @@ func (c *Client) Authenticate() error {
6866
am, err := m.tr.ReadMIMEHeader()
6967

7068
if err != nil && err.Error() != "EOF" {
71-
c.Close()
7269
Error(ECouldNotReadMIMEHeaders, err)
7370
return err
7471
}
7572

7673
if am.Get("Reply-Text") != "+OK accepted" {
77-
c.Close()
7874
Error(EInvalidPassword, c.Passwd)
7975
return fmt.Errorf(EInvalidPassword, c.Passwd)
8076
}
@@ -97,6 +93,7 @@ func NewClient(host string, port uint, passwd string, timeout int) (Client, erro
9793
}
9894

9995
if err := client.Authenticate(); err != nil {
96+
client.Close()
10097
return client, err
10198
}
10299

examples/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// I didn't write all of this code so you could say it's yours.
55
// MIT License
66

7-
package main
7+
package examples
88

99
import (
1010
"flag"

0 commit comments

Comments
 (0)