mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
committed by
Nitish Tiwari
parent
aaef18b1a3
commit
e96f19c867
@@ -19,9 +19,12 @@ package net
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// URL - improved JSON friendly url.URL.
|
||||
@@ -79,6 +82,27 @@ func (u *URL) UnmarshalJSON(data []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DialHTTP - dials the url to check the connection.
|
||||
func (u URL) DialHTTP() error {
|
||||
var client = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 2 * time.Second,
|
||||
}).DialContext,
|
||||
},
|
||||
}
|
||||
req, err := http.NewRequest("POST", u.String(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseURL - parses string into URL.
|
||||
func ParseURL(s string) (u *URL, err error) {
|
||||
var uu *url.URL
|
||||
|
||||
Reference in New Issue
Block a user