debug http client for attachments
This commit is contained in:
parent
6b2bf3b387
commit
34adc4b8dc
|
@ -158,11 +158,15 @@ func GetJunkTimeout(url string, timeout time.Duration) (junk.Junk, error) {
|
||||||
|
|
||||||
func fetchsome(url string) ([]byte, error) {
|
func fetchsome(url string) ([]byte, error) {
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
|
if debugMode {
|
||||||
|
client = debugClient
|
||||||
|
}
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error fetching %s: %s", url, err)
|
log.Printf("error fetching %s: %s", url, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
req.Header.Set("User-Agent", "honksnonk/5.0; "+serverName)
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
req = req.WithContext(ctx)
|
req = req.WithContext(ctx)
|
||||||
|
|
Loading…
Reference in New Issue