aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client.go')
-rw-r--r--client.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/client.go b/client.go
index 8b9cf5d..7c32b70 100644
--- a/client.go
+++ b/client.go
@@ -114,22 +114,27 @@ func (c *Client) post(s Signer, v interface{}) error {
var linksRe = regexp.MustCompile(`^<(.*)>;rel="(.*)"`)
func (c *Client) parseHeader(r *http.Response) {
- c.nonce <- r.Header.Get("Replay-Nonce")
+ if no := r.Header.Get("Replay-Nonce"); no != "" {
+ c.nonce <- no
+ }
- c.Location = r.Header.Get("Location")
+ if lo := r.Header.Get("Location"); lo != "" {
+ c.Location = lo
+ }
c.Link = make(Links)
- for _, l := range r.Header["Link"] {
- re := linksRe.FindStringSubmatch(l)
+ for _, li := range r.Header["Link"] {
+ re := linksRe.FindStringSubmatch(li)
if len(re) == 3 {
c.Link[re[2]] = re[1]
}
}
- c.RetryAfter = time.Second
- ra, err := strconv.Atoi(r.Header.Get("Retry-After"))
- if err == nil {
- c.RetryAfter *= time.Duration(ra)
+ if ra := r.Header.Get("Retry-After"); ra != "" {
+ n, err := strconv.Atoi(ra)
+ if err == nil {
+ c.RetryAfter = time.Second * time.Duration(n)
+ }
}
}
@@ -171,11 +176,6 @@ func (c *Client) Agree(a *Account) (*Registration, error) {
return r, c.post(a, r)
}
-func (c *Client) Query(a *Account) (*Registration, error) {
- r := &Registration{Resource: ResRegister}
- return r, c.post(a, r)
-}
-
func (c *Client) Authorize(a *Account, domain string) (*Authorization, error) {
r := &Authorization{
Resource: ResNewAuthz,
@@ -189,5 +189,5 @@ func (c *Client) Authorize(a *Account, domain string) (*Authorization, error) {
}
func (c Client) String() string {
- return fmt.Sprintf("Link: %v, Location: %v", c.Link, c.Location)
+ return fmt.Sprintf("Location: %v Links: %v", c.Location, c.Link)
}