MCPcopy Index your code
hub / github.com/smallstep/cli / postForm

Function postForm

command/oauth/cmd.go:714–726  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

712// application/json", without this header GitHub will use
713// application/x-www-form-urlencoded.
714func 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
729func (o *oauth) NewServer() (*httptest.Server, error) {

Callers 4

DoDeviceAuthorizationMethod · 0.85
deviceAuthzTokenPollMethod · 0.85
ExchangeMethod · 0.85

Calls 1

SetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…