Commit 6ebdde6
authored
trpc-proto-http: fix response header parsing in HttpConsumerInvoker (#135)
* trpc-proto-http: fix response header parsing in HttpConsumerInvoker
The previous implementation iterated over HeaderElement objects and
called element.getName() to extract header values. This only returns
the token before the first '=' or ';' delimiter, causing truncation
of composite header values such as:
Content-Type: application/json; charset=utf-8 -> "application/json"
X-Token: key=abc123 -> "key"
Set-Cookie: sessionId=abc; Path=/; HttpOnly -> "sessionId"
Fix this by calling header.getValue() directly to obtain the complete
header value, consistent with the approach already used in
Http2ConsumerInvoker. Also remove the now-unused HeaderElement import.
Add HttpConsumerInvokerTest covering:
- simple header values (no delimiters)
- composite values containing semicolons (core fix scenario)
- values containing equals signs
- multiple headers all stored correctly
- header values stored as byte[] (tRPC protocol consistency)
- non-200 status code throws TRpcException
- zero Content-Length returns empty response body
- complex cookie header with multiple semicolons and equals signs
- non-zero Content-Length with response body decoded correctly
* trpc-proto-http: fix comment1 parent 2c3fdd0 commit 6ebdde6
2 files changed
Lines changed: 404 additions & 5 deletions
File tree
- trpc-proto/trpc-proto-http/src
- main/java/com/tencent/trpc/proto/http/client
- test/java/com/tencent/trpc/proto/http/client
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 95 | + | |
| 96 | + | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
| |||
0 commit comments