添加优先顺序, 还没完成

This commit is contained in:
huangsimin 2018-11-21 18:58:49 +08:00
parent cad9668e4e
commit f44346a1d7

View File

@ -120,14 +120,20 @@ func ParseRawCURL(scurl string) (cURL *CURL, err error) {
return curl, nil
}
func judgeAndParseOptions(u *CURL, soption string) {
// ParseFunction 优先执行参数
type ParseFunction struct {
ExecuteFunction func(u *CURL, soption string)
ParamCURL *CURL
ParamData string
Prioty int
}
func judgeAndParseOptions(u *CURL, soption string) *ParseFunction {
switch prefix := soption[0:2]; prefix {
case "-H":
parseHeader(u, soption)
return &ParseFunction{ParamCURL: u, ParamData: soption, ExecuteFunction: parseHeader, Prioty: 1}
case "-X":
matches := regexp.MustCompile("-X +(.+)").FindStringSubmatch(soption)
method := strings.Trim(matches[1], "'")
u.Method = method
return &ParseFunction{ParamCURL: u, ParamData: soption, ExecuteFunction: parseOptX, Prioty: 1}
case "-A": // User-Agent 先后顺序的问题
parseHeader(u, soption)
case "-I":
@ -137,6 +143,12 @@ func judgeAndParseOptions(u *CURL, soption string) {
}
}
func parseOptX(u *CURL, soption string) {
matches := regexp.MustCompile("-X +(.+)").FindStringSubmatch(soption)
method := strings.Trim(matches[1], "'")
u.Method = method
}
func parseLongOption(u *CURL, soption string) {
// -d, --data <data> HTTP POST data
// --data-ascii <data> HTTP POST ASCII data