mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-29 22:56:39 +08:00
27 lines
514 B
Go
27 lines
514 B
Go
package image
|
|
|
|
import (
|
|
"net/http"
|
|
"one-api/common/config"
|
|
"one-api/common/utils"
|
|
"time"
|
|
)
|
|
|
|
var ImageHttpClients = &http.Client{
|
|
Transport: &http.Transport{
|
|
DialContext: utils.Socks5ProxyFunc,
|
|
Proxy: utils.ProxyFunc,
|
|
},
|
|
Timeout: 15 * time.Second,
|
|
}
|
|
|
|
func requestImage(url, method string) (*http.Response, error) {
|
|
res, err := utils.RequestBuilder(utils.SetProxy(config.ChatImageRequestProxy, nil), method, url, nil, nil)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ImageHttpClients.Do(res)
|
|
}
|