Skip to content
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

feat(response): 添加 SetBody 和 SetBodyStr 方法 #408

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

0xObjc
Copy link
Contributor

@0xObjc 0xObjc commented Dec 14, 2024

在使用中间件对响应体进行加密/解密处理时,直接修改 Response.Body
无法生效,因为 body 已被读取到内存中。新增这两个方法可以直接
设置解密后的内容到 body 字段,确保后续获取响应内容时
能正确获取到解密后的数据。

  • 添加 SetBody 方法用于设置字节数组形式的响应体
  • 添加 SetBodyStr 方法用于设置字符串形式的响应体

相关场景:

  • 响应体加密/解密中间件
  • 响应内容统一处理

在使用中间件对响应体进行加密/解密处理时,直接修改 Response.Body
无法生效,因为 body 已被读取到内存中。新增这两个方法可以直接
设置解密后的内容到 Response.body 字段,确保后续获取响应内容时
能正确获取到解密后的数据。

- 添加 SetBody 方法用于设置字节数组形式的响应体
- 添加 SetBodyStr 方法用于设置字符串形式的响应体

相关场景:
- 响应体加密/解密中间件
- 响应内容统一处理
@imroc
Copy link
Owner

imroc commented Dec 17, 2024

好主意,SetBodyStr 我改成 SetBodyString,规范点

@imroc imroc merged commit b639f8d into imroc:master Dec 17, 2024
2 checks passed
imroc added a commit that referenced this pull request Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants