feat: support query array in httpx.Parse (#4440)

This commit is contained in:
Kevin Wan
2024-11-02 21:55:37 +08:00
committed by GitHub
parent f822c9a94f
commit 18cb3141ba
6 changed files with 157 additions and 9 deletions

View File

@@ -20,10 +20,16 @@ func GetFormValues(r *http.Request) (map[string]any, error) {
}
params := make(map[string]any, len(r.Form))
for name := range r.Form {
formValue := r.Form.Get(name)
if len(formValue) > 0 {
params[name] = formValue
for name, values := range r.Form {
filtered := make([]string, 0, len(values))
for _, v := range values {
if len(v) > 0 {
filtered = append(filtered, v)
}
}
if len(filtered) > 0 {
params[name] = filtered
}
}