resty icon indicating copy to clipboard operation
resty copied to clipboard

set Content-Type to be empty

Open Myriad-Dreamin opened this issue 2 years ago • 0 comments

The Content-Type header maybe a part of oauth signed request.

https://github.com/go-resty/resty/blob/7dda6159eceee10c6cacc6f9d1637042f67423b0/middleware.go#L430-L436

One using resty might have to use PreRequestHook to make a request with empty content type.

resty.New().SetPreRequestHook(func(client *resty.Client, request *http.Request) error {
	request.Header.Set("Content-Type", "") // set empty string
	request.Header.Set("Request-Signature", makeSignature(
		privateKey,  strings.Join(getPathURL(request), request.Header["Content-Type"], getTimeString())))
	return nil
})

Myriad-Dreamin avatar Dec 04 '21 06:12 Myriad-Dreamin