(ctx context.Context, url string, bodyType string, body io.Reader)
| 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()) { |
| 1183 | return nil, fmt.Errorf("wrong URL (%q) for this server", url) |
| 1184 | } |
| 1185 | req := c.newRequest(ctx, "POST", url, body) |
| 1186 | req.Header.Set("Content-Type", bodyType) |
| 1187 | res, err := c.expect2XX(req) |
| 1188 | if err != nil { |
| 1189 | return nil, err |
| 1190 | } |
| 1191 | return res, nil |
| 1192 | } |
| 1193 | |
| 1194 | // newRequest creates a request with the authentication header, and with the |
| 1195 | // appropriate scheme and port in the case of self-signed TLS. |
no test coverage detected