(ctx context.Context, state string)
| 425 | } |
| 426 | |
| 427 | func (r *callbackProxyClient) register(ctx context.Context, state string) error { |
| 428 | form := url.Values{} |
| 429 | form.Add("state", state) |
| 430 | form.Add("location", r.callbackLocation) |
| 431 | req, err := http.NewRequestWithContext(ctx, "POST", r.server, strings.NewReader(form.Encode())) |
| 432 | if err != nil { |
| 433 | return err |
| 434 | } |
| 435 | req.Header.Set("User-Agent", ServerUserAgent("")) |
| 436 | req.Header.Set("Accept", "application/json") |
| 437 | req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 438 | |
| 439 | resp, err := r.httpClient.Do(req) |
| 440 | if err != nil { |
| 441 | return err |
| 442 | } |
| 443 | if resp.StatusCode != http.StatusCreated { |
| 444 | return fmt.Errorf("unable register state location: %d", resp.StatusCode) |
| 445 | } |
| 446 | |
| 447 | return nil |
| 448 | } |
| 449 | |
| 450 | func limitedJsonUnmarshal(body io.ReadCloser, n int, thing interface{}) error { |
| 451 | lr := io.LimitReader(body, int64(n+1)) |
no test coverage detected