MCPcopy
hub / github.com/perkeep/perkeep / Sign

Method Sign

pkg/client/client.go:1167–1179  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1165// and return them signed. It uses the same implementation details, such as gated
1166// requests, as Post.
1167func (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
1181func (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()) {

Callers

nothing calls this directly

Calls 4

SignHandlerMethod · 0.95
postMethod · 0.95
ReadAllMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected