// urlEncodedRequest returns a new url encoded request.
493132
func newURLEncodedRequest(method, endpoint string, params map[string]string) (*http.Request, error) {
	urlValues := url.Values{}
	for k, v := range params {
		urlValues.Add(k, v)
	}

	req, err := http.NewRequest(method, endpoint, strings.NewReader(urlValues.Encode()))
	if err != nil {
		return nil, err
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	return req, nil
}
764379
func (c *Certificate) AsCreateRequest() (api.CertificatesPost, error) {
	block, _ := pem.Decode(c.CertPEM)
	if block == nil {
		return api.CertificatesPost{}, errors.New("failed to decode certificate PEM")
	}

	return api.CertificatesPost{
		Certificate: base64.StdEncoding.EncodeToString(block.Bytes),
		CertificatePut: api.CertificatePut{
			Name: c.Name,
			Type: "client",
		},
	}, nil
}
782149
func (c *Client) NewRequest(method, path string) *Request {
	r := &Request{
		method: method,
		url:    c.Config.ApiAddress + path,
		params: make(map[string][]string),
	}
	return r
}
79993
func (c *Client) NewRequest(urlStr string) (req *Request, err error) {
	req, err = newRequest(c, urlStr)
	if err != nil {
		return
	}

	c.applyRequestHeaders(req)

	return
}
1120933
func DeleteRequest(urlStr string, resourceType string, id string) (*http.Request, error) {
	u, err := url.Parse(urlStr)
	if err != nil {
		return nil, jsh.ISE(fmt.Sprintf("Error parsing URL: %s", err.Error()))
	}

	setIDPath(u, resourceType, id)

	request, err := NewRequest("DELETE", u.String(), nil)
	if err != nil {
		return nil, jsh.ISE(fmt.Sprintf("Error creating DELETE request: %s", err.Error()))
	}

	return request, nil
}
339443
func (client *Client) ParseRequest(r *http.Request) ([]*Event, error) {
	return ParseRequest(client.channelSecret, r)
}
390156
func NopRequestDecoder(_ context.Context, _ *nats.Msg) (interface{}, error) {
	return nil, nil
}
128023
func (u *UploadRequest) Encode(w io.Writer) error {
	e := newUlReqEncoder(w)
	return e.Encode(u)
}
1078386
func EncodeUrl(query string) string {
	queryEnc := url.QueryEscape(query)
	if strings.HasPrefix(query, "!") {
		return fmt.Sprintf(baseUrl, queryEnc, "&no_redirect=1")
	}
	return fmt.Sprintf(baseUrl, queryEnc, "")
}
817950
func (c *consulClient) Encode(in []byte) string {
	return base64.URLEncoding.EncodeToString([]byte(in))
}
1007322
func (f RequestFunc) AuthenticateRequest(req *http.Request) (*Response, bool, error) {
	return f(req)
}
1258699
func (jolokiaClient *JolokiaClient) ExecuteReadRequest(jolokiaRequest *JolokiaRequest) (*JolokiaReadResponse, error) {
	resp, requestErr := jolokiaClient.executePostRequest(jolokiaRequest, "")
	if requestErr != nil {
		return nil, requestErr
	}
	var respJ JolokiaReadResponse
	decodeErr := json.Unmarshal([]byte(resp), &respJ)
	if decodeErr != nil {
		return nil, fmt.Errorf("Failed to decode Jolokia resp : %v", decodeErr)
	}
	return &respJ, nil
}
536503
func (f FormRequestBody) Encode() (requestBody io.Reader, contentType string, err error) {
	return strings.NewReader(url.Values(f).Encode()), "application/x-www-form-urlencoded", nil
}
214165
func urlDecode(hdrVal string) string {
	if valUnescaped, errUnescaping := url.QueryUnescape(hdrVal); errUnescaping == nil {
		hdrVal = valUnescaped
	}
	return hdrVal
}
1059654
func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error {
	if err := json.NewDecoder(r.Body).Decode(v); err != nil {
		if err == io.EOF && ignoreEOF {
			return nil
		}
		return fmt.Errorf("error decoding request body: %v", err)
	}
	return nil
}
962379
func (c *Client) NewRequest(rawurl string) (*Request, error) {
	httpreq, err := buildRequest(c, rawurl)
	if httpreq == nil {
		return nil, err
	}

	return &Request{c.HttpClient, nil, httpreq.URL.Query(), c.Cacher, httpreq}, err
}
571909
func getCanonicalRequest(extractedSignedHeaders http.Header, payload, queryStr, urlPath, method string) string {
	rawQuery := strings.Replace(queryStr, "+", "%20", -1)
	encodedPath := s3utils.EncodePath(urlPath)
	canonicalRequest := strings.Join([]string{
		method,
		encodedPath,
		rawQuery,
		getCanonicalHeaders(extractedSignedHeaders),
		getSignedHeaders(extractedSignedHeaders),
		payload,
	}, "\n")
	return canonicalRequest
}