clientcache commands now can output curl strings (#4042)
This commit is contained in:
1 parent
b71d134e06
commit
9aab26e91b
8 files changed
+131
-21
No files matched your search
@@ -19,10 +19,18 @@ var LastOutputStringError *OutputStringError
|
||||
|
||||
type OutputStringError struct {
|
||||
*retryablehttp.Request
|
||||
unixSocket string
|
||||
parsingError error
|
||||
parsedCurlString string
|
||||
}
|
||||
|
||||
func NewOutputDomainSocketCurlStringError(req *retryablehttp.Request, socketAddr string) *OutputStringError {
|
||||
return &OutputStringError{
|
||||
Request: req,
|
||||
unixSocket: socketAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *OutputStringError) Error() string {
|
||||
if d.parsedCurlString == "" {
|
||||
d.parseRequest()
|
||||
@@ -46,6 +54,9 @@ func (d *OutputStringError) parseRequest() {
|
||||
if d.Request.Method != "GET" {
|
||||
d.parsedCurlString = fmt.Sprintf("%s -X %s", d.parsedCurlString, d.Request.Method)
|
||||
}
|
||||
if d.unixSocket != "" {
|
||||
d.parsedCurlString = fmt.Sprintf("%s --unix-socket %s", d.parsedCurlString, d.unixSocket)
|
||||
}
|
||||
for k, v := range d.Request.Header {
|
||||
for _, h := range v {
|
||||
if strings.ToLower(k) == "authorization" {
|
||||
|
||||
Reference in new issue
Block a user