mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #14956 from fatmcgav/openstack_sort_headers
provider/openstack: Sort request/response headers whilst debugging
This commit is contained in:
commit
527b7af79e
@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
|
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
|
||||||
@ -78,7 +79,11 @@ func (lrt *LogRoundTripper) logRequest(original io.ReadCloser, headers http.Head
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Openstack Request headers:\n%s", strings.Join(RedactHeaders(headers), "\n"))
|
// Sort the headers for consistency
|
||||||
|
redactedHeaders := RedactHeaders(headers)
|
||||||
|
sort.Strings(redactedHeaders)
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Openstack Request headers:\n%s", strings.Join(redactedHeaders, "\n"))
|
||||||
|
|
||||||
// Handle request contentType
|
// Handle request contentType
|
||||||
contentType := headers.Get("Content-Type")
|
contentType := headers.Get("Content-Type")
|
||||||
@ -95,7 +100,11 @@ func (lrt *LogRoundTripper) logRequest(original io.ReadCloser, headers http.Head
|
|||||||
// logResponse will log the HTTP Response details.
|
// logResponse will log the HTTP Response details.
|
||||||
// If the body is JSON, it will attempt to be pretty-formatted.
|
// If the body is JSON, it will attempt to be pretty-formatted.
|
||||||
func (lrt *LogRoundTripper) logResponse(original io.ReadCloser, headers http.Header) (io.ReadCloser, error) {
|
func (lrt *LogRoundTripper) logResponse(original io.ReadCloser, headers http.Header) (io.ReadCloser, error) {
|
||||||
log.Printf("[DEBUG] Openstack Response headers:\n%s", strings.Join(RedactHeaders(headers), "\n"))
|
// Sort the headers for consistency
|
||||||
|
redactedHeaders := RedactHeaders(headers)
|
||||||
|
sort.Strings(redactedHeaders)
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Openstack Response headers:\n%s", strings.Join(redactedHeaders, "\n"))
|
||||||
|
|
||||||
contentType := headers.Get("Content-Type")
|
contentType := headers.Get("Content-Type")
|
||||||
if strings.HasPrefix(contentType, "application/json") {
|
if strings.HasPrefix(contentType, "application/json") {
|
||||||
|
Loading…
Reference in New Issue
Block a user