func()

in bayeux.go [116:138]


func (b *Bayeux) newHTTPRequest(ctx context.Context, body string, route string) (*http.Request, error) {
	var jsonStr = []byte(body)
	req, err := http.NewRequest("POST", route, bytes.NewBuffer(jsonStr))
	if err != nil {
		return nil, fmt.Errorf("bad Call request: %w", err)
	}
	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	default:
		req = req.WithContext(ctx)

		req.Header.Add("Content-Type", "application/json")
		req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", b.creds.AccessToken))
		// Per Stackexchange comment, passing back cookies is required though undocumented in Salesforce API
		// We were unable to get process working without passing cookies back to SF server.
		// SF Reference: https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/intro_client_specs.htm
		for _, cookie := range b.id.cookies {
			req.AddCookie(cookie)
		}
	}
	return req, nil
}