From f37c6e605107764cd1fd6d3fbd3d975ea8a3b8b8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 21 Dec 2015 01:06:12 +0100 Subject: WIP --- client.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index 7a023b5..4737995 100644 --- a/client.go +++ b/client.go @@ -75,7 +75,7 @@ func (c *Client) post(s Signer, v interface{}) error { if err != nil { return err } - log.Println(string(body)) + log.Println("POST", string(body)) signed, err := s.Sign(body, c) if err != nil { @@ -88,6 +88,8 @@ func (c *Client) post(s Signer, v interface{}) error { } defer resp.Body.Close() c.parseHeader(resp) + log.Println("STATUS", resp.Status) + log.Println("HEADER", c) if resp.StatusCode >= http.StatusBadRequest { var p Problem @@ -168,11 +170,16 @@ func (c *Client) Register(a *Account) (*Registration, error) { // Agree to TOS func (c *Client) Agree(a *Account) (*Registration, error) { + tos := c.Link["terms-of-service"] + if tos == "" { + return nil, errors.New("TOS agreed") + } r := &Registration{ Resource: ResRegister, Contact: a.Contact, - Agreement: c.Link["terms-of-service"], + Agreement: tos, } + log.Println("TOS", tos) return r, c.post(a, r) } @@ -191,3 +198,18 @@ func (c *Client) Authorize(a *Account, domain string) (*Authorization, error) { func (c Client) String() string { return fmt.Sprintf("Location: %v Links: %v", c.Location, c.Link) } + +//////////////////////////////////////////////////////////////////////// + +// Register +// 1. new-reg +// arg: contact +// StatusCreated (201) or StatusConflict (409) +// Response: Location, Link +// 2. reg +// arg: contact, tos +// StatusOk + +// Authorize + +// Certificate -- cgit v1.2.3