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"
|
||||
"log"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"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
|
||||
}
|
||||
|
||||
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
|
||||
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.
|
||||
// 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) {
|
||||
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")
|
||||
if strings.HasPrefix(contentType, "application/json") {
|
||||
|
|
Loading…
Reference in New Issue