Fix not closed http.client.
This commit is contained in:
parent
66f5b5bb53
commit
4a3594096b
4
go.mod
4
go.mod
@ -5,10 +5,10 @@ go 1.13
|
||||
require (
|
||||
github.com/RichardKnop/machinery v1.7.3
|
||||
github.com/Songmu/go-httpdate v1.0.0
|
||||
github.com/go-redis/redis v6.15.6+incompatible
|
||||
github.com/go-redis/redis v6.15.7+incompatible
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/spf13/cobra v0.0.6
|
||||
github.com/spf13/viper v1.6.2
|
||||
github.com/yukimochi/httpsig v0.1.3
|
||||
)
|
||||
|
@ -39,11 +39,11 @@ func sendActivity(inboxURL string, KeyID string, body []byte, publicKey *rsa.Pri
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("%s (golang net/http; Activity-Relay %s; %s)", viper.GetString("relay_servicename"), version, hostURL.Host))
|
||||
req.Header.Set("Date", httpdate.Time2Str(time.Now()))
|
||||
appendSignature(req, &body, KeyID, publicKey)
|
||||
client := &http.Client{Timeout: time.Duration(5) * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
fmt.Println(inboxURL, resp.StatusCode)
|
||||
if resp.StatusCode/100 != 2 {
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
@ -27,6 +28,7 @@ var (
|
||||
hostPrivatekey *rsa.PrivateKey
|
||||
redisClient *redis.Client
|
||||
machineryServer *machinery.Server
|
||||
httpClient *http.Client
|
||||
)
|
||||
|
||||
func relayActivity(args ...string) error {
|
||||
@ -85,6 +87,7 @@ func initConfig() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
httpClient = &http.Client{Timeout: time.Duration(5) * time.Second}
|
||||
|
||||
Actor.GenerateSelfKey(hostURL, &hostPrivatekey.PublicKey)
|
||||
newNullLogger := NewNullLogger()
|
||||
|
Loading…
x
Reference in New Issue
Block a user