enable bodyclose
Checks whether HTTP response body is closed successfully. Signed-off-by: Kai Xia <kaix+github@fastmail.com>
This commit is contained in:
parent
ade966d773
commit
bbbe766caa
3 changed files with 8 additions and 3 deletions
|
|
@ -28,7 +28,6 @@ linters:
|
||||||
- wsl_v5
|
- wsl_v5
|
||||||
|
|
||||||
# TODO: Disabled, because they are failing at the moment, we should fix them and enable (step by step)
|
# TODO: Disabled, because they are failing at the moment, we should fix them and enable (step by step)
|
||||||
- bodyclose
|
|
||||||
- contextcheck
|
- contextcheck
|
||||||
- dogsled
|
- dogsled
|
||||||
- embeddedstructfieldcheck
|
- embeddedstructfieldcheck
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,10 @@ func (c *OneBotChannel) connect() error {
|
||||||
header["Authorization"] = []string{"Bearer " + c.config.AccessToken}
|
header["Authorization"] = []string{"Bearer " + c.config.AccessToken}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, _, err := dialer.Dial(c.config.WSUrl, header)
|
conn, resp, err := dialer.Dial(c.config.WSUrl, header)
|
||||||
|
if resp != nil {
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,10 @@ func (c *WhatsAppChannel) Start(ctx context.Context) error {
|
||||||
dialer := websocket.DefaultDialer
|
dialer := websocket.DefaultDialer
|
||||||
dialer.HandshakeTimeout = 10 * time.Second
|
dialer.HandshakeTimeout = 10 * time.Second
|
||||||
|
|
||||||
conn, _, err := dialer.Dial(c.url, nil)
|
conn, resp, err := dialer.Dial(c.url, nil)
|
||||||
|
if resp != nil {
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect to WhatsApp bridge: %w", err)
|
return fmt.Errorf("failed to connect to WhatsApp bridge: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue