Compare commits

..

No commits in common. "c0397c568ed02cb855912cf234928282ca71db27" and "d437bfae2bc354e9c507fe9d7e61b14eca38a7ac" have entirely different histories.

1 changed files with 3 additions and 16 deletions

View File

@ -22,7 +22,6 @@ type Request struct {
Files map[string]string `json:"files"` // todo 处理 Files
Raw string `json:"raw"` // 原始请求数据
JsonByte []byte `json:"json_raw"` // JSON格式请求数据 todo 多层 嵌套
Xml []byte `json:"xml"` // xml
}
// 响应结构体
@ -70,26 +69,14 @@ func (r *Request) getData() io.Reader {
urlValues.Add(key, value)
}
reqBody = urlValues.Encode()
if _, ex := r.Headers["Content-Type"]; !ex {
r.Headers["Content-Type"] = "application/x-www-form-urlencoded"
}
r.Headers["Content-Type"] = "application/x-www-form-urlencoded"
} else if r.Json != nil {
bytesData, _ := json.Marshal(r.Json)
reqBody = string(bytesData)
if _, ex := r.Headers["Content-Type"]; !ex {
r.Headers["Content-Type"] = "application/json"
}
r.Headers["Content-Type"] = "application/json"
} else if r.JsonByte != nil {
reqBody = string(r.JsonByte)
if _, ex := r.Headers["Content-Type"]; !ex {
r.Headers["Content-Type"] = "application/json"
}
} else if r.Xml != nil {
reqBody = string(r.Xml)
if _, ex := r.Headers["Content-Type"]; !ex {
r.Headers["Content-Type"] = "application/xml"
}
r.Headers["Content-Type"] = "application/json"
}
return strings.NewReader(reqBody)
}