// VisitWebPage is part of the httpbakery.Visitor interface. func (v *Visitor) VisitWebPage(client *httpbakery.Client, methodURLs map[string]*url.URL) error { methodURL := methodURLs[authMethod] if methodURL == nil { return httpbakery.ErrMethodNotSupported } password, err := v.getPassword(v.username) if err != nil { return err } // POST to the URL with username and password. resp, err := client.PostForm(methodURL.String(), url.Values{ "user": {v.username}, "password": {password}, }) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode == http.StatusOK { return nil } var jsonError httpbakery.Error if err := json.NewDecoder(resp.Body).Decode(&jsonError); err != nil { return errors.Annotate(err, "unmarshalling error") } return &jsonError }