HttpTransferCache collapses distinct binary POST bodies into the same cache key
- 主要语言
- TypeScript
- 星标
- 101k
- 派生
- 27.5k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 288
描述
### Which @angular/* package(s) are the source of the bug?
common / http
### Is this a regression?
No
### Description
With POST requests enabled in `HttpTransferCache`, two requests with different binary bodies can end up sharing one cache entry. This matters for valid POST-based APIs such as Protobuf and gRPC, where the request body carries the input. The same cache-key rule also applies to other POST APIs, including GraphQL requests.
I reproduced this with two read-only Protobuf requests to the same URL. The bodies are valid, but different:
```text
document 100: 0864 document 200: 08c801
```
Angular should treat these as separate requests and cache their responses separately. Instead, the request for document `200` gets the cached response for document `100`; it never reaches the origin.
```ts
else if (typeof serializedBody !== 'string') {
serializedBody = '';
}
```
`HttpRequest.serializeBody()` returns a `Blob` as-is. Because a `Blob` is not a string, `makeCacheKey()` turns it into `''`. That means both Protobuf payloads have the same cache-key input before hashing.
### Please provide a link to a minimal reproduction of the bug
See Repository: https://github.com/SkyZeroZx/angular-protobuf-transfercache-poc
贡献指南
调研方向
先在 common/http 中跟踪 makeCacheKey 和 HttpRequest.serializeBody(),然后使用链接的 angular-protobuf-transfercache-poc 重现该问题。当不同的二进制 POST body 产生不同的缓存键,且它们的响应不会被共享时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- api, performance
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 72/100