diff --git a/parse_curl.go b/parse_curl.go index 0bf89c3..2b40e06 100644 --- a/parse_curl.go +++ b/parse_curl.go @@ -124,12 +124,16 @@ func judgeAndParseOptions(u *CURL, soption string) { switch prefix := soption[0:2]; prefix { case "-H": parseHeader(u, soption) - case "--": - parseLongOption(u, soption) case "-X": matches := regexp.MustCompile("-X +(.+)").FindStringSubmatch(soption) method := strings.Trim(matches[1], "'") u.Method = method + case "-A": // User-Agent 先后顺序的问题 + parseHeader(u, soption) + case "-I": + u.Method = "HEAD" + case "--": + parseLongOption(u, soption) } } @@ -163,7 +167,8 @@ func parseLongOption(u *CURL, soption string) { case "data": parseBodyASCII(u, data) } - + case regexp.MustCompile("^--header").MatchString(soption): + parseHeader(u, soption) } } @@ -220,7 +225,6 @@ func parseBodyBinary(u *CURL, data string) { } func parseHeader(u *CURL, soption string) { - matches := regexp.MustCompile(`'([^:]+): ([^']+)'`).FindAllStringSubmatch(soption, 1)[0] key := matches[1] value := matches[2]