fix: httpx.ParseJsonBody error when request has []byte field #4450 (#4471)

This commit is contained in:
Devin
2025-01-22 21:35:32 +08:00
committed by GitHub
parent 238c92aaa9
commit cbcacf31c1
2 changed files with 29 additions and 1 deletions

View File

@@ -748,7 +748,15 @@ func (u *Unmarshaler) processFieldTextUnmarshaler(fieldType reflect.Type, value
return true, tval.UnmarshalText(mv)
}
}
//[]byte
if fieldType.Kind() == reflect.Slice && fieldType.Elem().Kind() == reflect.Uint8 {
b, err := base64.StdEncoding.DecodeString(mapValue.(string))
if err != nil {
return false, err
}
value.SetBytes(b)
return true, nil
}
return false, nil
}