Commit 9646326
authored
Only send a 304 when the request was a GET (#957)
The 304 branch in `connectUnaryHandlerConn.Close` works out whether it's
answering a GET by counting query parameters, and `Peer.Query` gets
filled in for every method. So any POST that happens to carry a query
string gets the conditional-GET treatment. Same handler returning the
same `NewNotModifiedError`, one extra param on the URL:
```
POST /svc/Method -> 500 application/json {"code":"unknown","message":"not modified"}
POST /svc/Method?foo=bar -> 304 no body
```
The message and any error details go with the body, and a connect-go
client turns the second one into `unknown: 304 Not Modified`. Thats not
hard to land on - a base URL with a param baked into it, or a proxy
tacking on cache-busting ones.
`mergeResponseHeader` a few lines down already checks `request.Method`,
and the client side only honours a 304 for GETs, so Im fairly confident
the method is what the query count was standing in for.
The test bolts the query string on in a wrapper handler rather than
through the client, beacuse a connect-go client won't put one on a POST
by itself. `TestGetNotModified` still covers the GET side.
Signed-off-by: Iain <iain1970@protonmail.com>1 parent 2a02fea commit 9646326
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
205 | 224 | | |
206 | 225 | | |
207 | 226 | | |
| |||
863 | 882 | | |
864 | 883 | | |
865 | 884 | | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
866 | 896 | | |
867 | 897 | | |
868 | 898 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
731 | | - | |
| 731 | + | |
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
| |||
0 commit comments