postForm simulates http.PostForm but adds the header "Accept: application/json", without this header GitHub will use application/x-www-form-urlencoded.
(rawurl string, data url.Values)
| 712 | // application/json", without this header GitHub will use |
| 713 | // application/x-www-form-urlencoded. |
| 714 | func postForm(rawurl string, data url.Values) (*http.Response, error) { |
| 715 | req, err := http.NewRequest("POST", rawurl, strings.NewReader(data.Encode())) // #nosec G704 -- request intentionally relies on user data |
| 716 | if err != nil { |
| 717 | return nil, fmt.Errorf("create POST %s request failed: %w", rawurl, err) |
| 718 | } |
| 719 | |
| 720 | // Prevents re-use of TCP connections between requests. |
| 721 | req.Close = true |
| 722 | |
| 723 | req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 724 | req.Header.Set("Accept", "application/json") |
| 725 | return http.DefaultClient.Do(req) // #nosec G704 -- request intentionally relies on user configuration |
| 726 | } |
| 727 | |
| 728 | // NewServer creates http server |
| 729 | func (o *oauth) NewServer() (*httptest.Server, error) { |
no test coverage detected
searching dependent graphs…