Http Request / Redirect Clarification #2008
Unanswered
billygcode
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am currently investigating automatic redirects in aws-sdk-go-v2. From what I can see from the source code, answered questions on here, debugging, and testing, the automatic redirect is for 307 and 308.
After looking at the source code and debugging, I noticed that the SDK creates a http.Request using smithy-go( https://github.com/aws/smithy-go/blob/v1.13.5/transport/http/request.go#L161 ) and then proceeds to send the request using the standard Golang library (https://github.com/golang/go/blob/master/src/net/http/client.go). Am I correct?
If this is correct, smithy-go creates a http.Request without the function variable getBody() which is checked when the request is 307 or 308 with the standard golang library.
if ireq.GetBody == nil && ireq.outgoingLength() != 0 { shouldRedirect = false }
(https://github.com/golang/go/blob/master/src/net/http/client.go#L522)
This means that ireq.GetBody is always nil, and will never redirect when the request has an outgoingLength that is not 0. So any request with a body (e.g. putObject()) will not redirect automatically, everything else should. All my tests show automatic redirect for all functions except for the ones with a body provided.
Is this correct? If not, how are the request created and sent out, where is the getBody() initialized?
Beta Was this translation helpful? Give feedback.
All reactions