-
Notifications
You must be signed in to change notification settings - Fork 251
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
Sets request's GetBody field on create wrapper #207
Conversation
This commit addresses two key issues: - Upon receiving a temporary redirect, net/http will only preserve the request's body if GetBody() is defined. - Upon receiving a GOAWAY frame, the client will create a new connection. We define GetBody() in order to reuse the body sent in the last stream on the now terminated connection.
528a6ca
to
f95735f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we needed to test for 307/308 response codes before setting the GetBody, but it looks like Client.Do
is pretty clear that it'll only invoke this helper if it thinks it should. So that works for me!
I 💯 appreciate the additional tests! Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little late on the review but thought I would share my findings which were not blocking anyway
|
||
func TestClient_RedirectWithBody(t *testing.T) { | ||
var redirects int32 | ||
// Mock server which always responds 200. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not technically true
w.Header().Set("Location", "/target") | ||
w.WriteHeader(http.StatusTemporaryRedirect) | ||
case "/target": | ||
atomic.AddInt32(&redirects, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this test that the body was received?
Closes #121
This commit addresses two key issues:
Not entirely sure why the fix was never merged, but here we are :) Credits to @rgb-24bit