aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-23 12:21:55 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-23 12:21:55 +0100
commit21376df84168ce1adc74221fd0ab39fca28b70be (patch)
tree88de4a86974f24b4826afefd738e36ed2847d453 /client.go
parenta6164ce0b210aaafff25dafbaee191bdf95628e2 (diff)
Use builtin type for Location
Diffstat (limited to 'client.go')
-rw-r--r--client.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/client.go b/client.go
index 4816c0b..143b79e 100644
--- a/client.go
+++ b/client.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "net/url"
"regexp"
"strconv"
"time"
@@ -23,7 +24,7 @@ type Client struct {
type nextStep struct {
Link Links
- Location string
+ Location *url.URL
RetryAfter time.Duration
}
@@ -125,7 +126,7 @@ var linksRe = regexp.MustCompile(`^<(.*)>;rel="(.*)"`)
func parseHeader(r *http.Response) nextStep {
var ns nextStep
- if lo := r.Header.Get("Location"); lo != "" {
+ if lo, err := r.Location(); err == nil {
ns.Location = lo
}
@@ -181,7 +182,7 @@ func (c *Client) Register(a *Account) error {
case http.StatusConflict:
// Query Location
r = &Registration{Resource: ResRegister}
- resp, err = c.post(ns.Location, a, r)
+ resp, err = c.post(ns.Location.String(), a, r)
if err != nil {
return err
}
@@ -194,7 +195,7 @@ func (c *Client) Register(a *Account) error {
Contact: a.Contact,
Agreement: tos,
}
- _, err = c.post(ns.Location, a, r)
+ _, err = c.post(ns.Location.String(), a, r)
}
}
return err