From 7c18e85798e87342e889b02c4d538b259128b9c1 Mon Sep 17 00:00:00 2001 From: Duarte Avelar Date: Tue, 2 Jun 2015 11:20:27 -0400 Subject: [PATCH] Changes the requestXml method to not use the default 30 second get timeout, uses 3 seconds instead. --- goupnp.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/goupnp.go b/goupnp.go index 8cd20c2..7799a32 100644 --- a/goupnp.go +++ b/goupnp.go @@ -19,7 +19,7 @@ import ( "fmt" "net/http" "net/url" - + "time" "golang.org/x/net/html/charset" "github.com/huin/goupnp/httpu" @@ -64,7 +64,6 @@ func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) { maybe := &results[i] loc, err := response.Location() if err != nil { - maybe.Err = ContextError{"unexpected bad location from search", err} continue } @@ -93,7 +92,11 @@ func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) { } func requestXml(url string, defaultSpace string, doc interface{}) error { - resp, err := http.Get(url) + timeout := time.Duration(3 * time.Second) + client := http.Client{ + Timeout: timeout, + } + resp, err := client.Get(url) if err != nil { return err }