Documentation ¶
Index ¶
- func CalculateTimeout(fileLength int64, minRate, defaultMinRate rate.Rate, ...) time.Duration
- func ConvertHeaders(headers []string) map[string]string
- func ConvertTimeIntToString(timestamp int64) (string, error)
- func ConvertTimeStringToInt(timeStr string) (int64, error)
- func ExtractHost(hostAndPort string) string
- func FilterURLParam(url string, filters []string) string
- func GetAllIPs() (ipList []string, err error)
- func GetIPAndPortFromNode(node string, defaultPort int) (string, int)
- func IsValidIP(ip string) bool
- func IsValidURL(urlStr string) bool
- func NetLimit() *rate.Rate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateTimeout ¶ added in v1.0.0
func CalculateTimeout(fileLength int64, minRate, defaultMinRate rate.Rate, reservedTime time.Duration) time.Duration
CalculateTimeout calculates the timeout(in seconds) according to the fileLength and the min rate of network.
The 0 will be returned when both minRate and defaultMinRate both are <=0.
func ConvertHeaders ¶
ConvertHeaders converts headers from array type to map type for http request.
func ConvertTimeIntToString ¶
ConvertTimeIntToString converts an int64 timestamp to a string time.
func ConvertTimeStringToInt ¶
ConvertTimeStringToInt converts a string time to an int64 timestamp.
func ExtractHost ¶
ExtractHost extracts host ip from the giving string.
func FilterURLParam ¶
FilterURLParam filters request queries in URL. Eg: If you pass parameters as follows:
url: http://a.b.com/locate?key1=value1&key2=value2&key3=value3 filter: key2
and then you will get the following value as the return:
http://a.b.com/locate?key1=value1&key3=value3
func GetIPAndPortFromNode ¶
GetIPAndPortFromNode returns ip and port by parsing the node value. It will return defaultPort as the value of port when the node is a string without port or with an illegal port.
func IsValidURL ¶
IsValidURL returns whether the string url is a valid HTTP URL.
Types ¶
This section is empty.