Sign sends a request to the sign handler on server to sign the contents of r, and return them signed. It uses the same implementation details, such as gated requests, as Post.
(ctx context.Context, server string, r io.Reader)
| 1165 | // and return them signed. It uses the same implementation details, such as gated |
| 1166 | // requests, as Post. |
| 1167 | func (c *Client) Sign(ctx context.Context, server string, r io.Reader) (signed []byte, err error) { |
| 1168 | signHandler, err := c.SignHandler() |
| 1169 | if err != nil { |
| 1170 | return nil, err |
| 1171 | } |
| 1172 | signServer := strings.TrimSuffix(server, "/") + signHandler |
| 1173 | resp, err := c.post(ctx, signServer, "application/x-www-form-urlencoded", r) |
| 1174 | if err != nil { |
| 1175 | return nil, err |
| 1176 | } |
| 1177 | defer resp.Body.Close() |
| 1178 | return io.ReadAll(resp.Body) |
| 1179 | } |
| 1180 | |
| 1181 | func (c *Client) post(ctx context.Context, url string, bodyType string, body io.Reader) (*http.Response, error) { |
| 1182 | if !c.sameOrigin && !strings.HasPrefix(url, c.discoRoot()) { |
nothing calls this directly
no test coverage detected