aboutsummaryrefslogtreecommitdiff
path: root/gopherschwift/package.go
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2020-02-24 16:05:42 +0100
committerStefan Majewsky <stefan.majewsky@sap.com>2020-02-24 16:05:42 +0100
commit3857990bb9f705ed06f8ac2a18ba7d4a732f4274 (patch)
tree5435eadf10514d125cef19fa52144490844c25ee /gopherschwift/package.go
parente1b3d5e2efc913f52df74291c0c90efb346faa0e (diff)
downloadgo-schwift-3857990bb9f705ed06f8ac2a18ba7d4a732f4274.tar.gz
guard against Swift sending 100 status too early
Diffstat (limited to 'gopherschwift/package.go')
-rw-r--r--gopherschwift/package.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/gopherschwift/package.go b/gopherschwift/package.go
index 3889735..1d0d724 100644
--- a/gopherschwift/package.go
+++ b/gopherschwift/package.go
@@ -120,6 +120,20 @@ func (g *backend) do(req *http.Request, afterReauth bool) (*http.Response, error
if err != nil {
return nil, err
}
+
+ //Swift is stupid: Even though we send `Expect: 100-continue`, it doesn't
+ //help. Swift will right away answer `100 Continue` and ONLY THEN actually
+ //check the token (at least in our prod setup).
+ //
+ //To increase the chance that this does not completely break this request,
+ //reset the reader if it implements Seek().
+ if seekableReqBody, ok := req.Body.(io.Seeker); ok {
+ _, err := seekableReqBody.Seek(0, io.SeekStart)
+ if err != nil {
+ return nil, err
+ }
+ }
+
//restart request with new token
return g.do(req, true)
}