Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion http2curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func bashEscape(str string) string {
return `'` + strings.Replace(str, `'`, `'\''`, -1) + `'`
}

func bracketEscape(str string) string {
return strings.Replace(strings.Replace(str, `[`, `\[`, -1), `]`, `\]`, -1)
}

// GetCurlCommand returns a CurlCommand corresponding to an http.Request
func GetCurlCommand(req *http.Request) (*CurlCommand, error) {
if req.URL == nil {
Expand Down Expand Up @@ -77,7 +81,7 @@ func GetCurlCommand(req *http.Request) (*CurlCommand, error) {
command.append("-H", bashEscape(fmt.Sprintf("%s: %s", k, strings.Join(req.Header[k], " "))))
}

command.append(bashEscape(requestURL))
command.append(bashEscape(bracketEscape(requestURL)))

command.append("--compressed")

Expand Down