mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
fix: re-use connections in webhook/elasticsearch (#9461)
- elasticsearch client should rely on the SDK helpers instead of pure HTTP calls. - webhook shouldn't need to check for IsActive() for all notifications, failure should be delayed. - Remove DialHTTP as its never used properly Fixes #9460
This commit is contained in:
@@ -20,14 +20,10 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// URL - improved JSON friendly url.URL.
|
||||
@@ -85,34 +81,6 @@ func (u *URL) UnmarshalJSON(data []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DialHTTP - dials the url to check the connection.
|
||||
func (u URL) DialHTTP(transport *http.Transport) error {
|
||||
if transport == nil {
|
||||
transport = &http.Transport{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 2 * time.Second,
|
||||
}).DialContext,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var client = &http.Client{
|
||||
Transport: transport,
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", u.String(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseHTTPURL - parses a string into HTTP URL, string is
|
||||
// expected to be of form http:// or https://
|
||||
func ParseHTTPURL(s string) (u *URL, err error) {
|
||||
|
||||
Reference in New Issue
Block a user