-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
无法获取requestBodyStream #949
Labels
question
Further information is requested
Comments
是不是发的 GET 请求。 |
和 GET 请求没关系,本地最新没有复现 |
他前端代码显示的是 post 请求 |
不太应该,看看能否提供一个postman/curl的复现方式 @Cruii |
curl调用 curl --location 'http://localhost:8888/webauthn/reg/verify' \
--header 'Content-Type: application/json' \
--data '{
"attr": {
"id": "rlCtfJsTRSxhl9cH65xvEi8UOIM_O1UyY__Ij1I_-qE",
"rawId": "rlCtfJsTRSxhl9cH65xvEi8UOIM_O1UyY__Ij1I_-qE",
"response": {
"attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVikSZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2NFAAAAAAAAAAAAAAAAAAAAAAAAAAAAIK5QrXybE0UsYZfXB-ucbxIvFDiDPztVMmP_yI9SP_qhpQECAyYgASFYIFiboyWQGfqZh_4zRT3H8BVXxb4Ek3MmGEvxAj3fM1TVIlgg7bpcX5y9t9Q2vI54OjYJDuSVRovqVPx05MmofsL1VAM",
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoielVqR3hWTGJGQ3RudXZnMW84RGlXNGF2TmR3Y3Q2alRwUkdOanZHOVhjNCIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6NTE3MyIsImNyb3NzT3JpZ2luIjpmYWxzZX0",
"transports": [
"internal"
],
"publicKeyAlgorithm": -7,
"publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWJujJZAZ-pmH_jNFPcfwFVfFvgSTcyYYS_ECPd8zVNXtulxfnL231Da8jng6NgkO5JVGi-pU_HTkyah-wvVUAw",
"authenticatorData": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2NFAAAAAAAAAAAAAAAAAAAAAAAAAAAAIK5QrXybE0UsYZfXB-ucbxIvFDiDPztVMmP_yI9SP_qhpQECAyYgASFYIFiboyWQGfqZh_4zRT3H8BVXxb4Ek3MmGEvxAj3fM1TVIlgg7bpcX5y9t9Q2vI54OjYJDuSVRovqVPx05MmofsL1VAM"
},
"type": "public-key",
"clientExtensionResults": {},
"authenticatorAttachment": "platform"
}
}' handler // VerifyRegistration .
// @router /webauthn/reg/verify [POST]
func VerifyRegistration(ctx context.Context, c *app.RequestContext) {
var err error
var req webauthnModel.WebauthnRegVerifyReq
err = c.BindAndValidate(&req)
if err != nil {
c.String(consts.StatusBadRequest, err.Error())
return
}
s := c.RequestBodyStream()
fmt.Println(s) // 输出 {},断点调试类型 protocol.noBody
} main func main() {
redis.InitClient()
svcclient.InitSvcClient()
h := server.Default(server.WithStreamBody(true), server.WithTransport(standard.NewTransporter))
h.Use(cors.New(cors.Config{
AllowAllOrigins: true,
}))
err := webauthn.Init()
if err != nil {
panic(err)
}
register(h)
h.Spin()
} |
3 tasks
如果用流式读请求内容的话就不要先用 BindAndValidate 绑定了,两者选一个即可 |
了解了,也就是说BindAndValidate处理后会把流关闭吗 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Question
在开启StreamBody的情况下,获取到的bodyStream为noBody
Reproducible Code
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
前端调用代码
端点调试
Hertz version:
v0.6.7
Environment:
The output of
go env
.Additional context
Add any other context about the question here.
The text was updated successfully, but these errors were encountered: