From f38a0b888a7b23aedea6a2a0891b6102e8d0994c Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Thu, 31 Aug 2017 22:58:55 -0700 Subject: [PATCH] udpate oreo for request replays --- glide.lock | 2 +- vendor/github.com/coryb/oreo/oreo.go | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/glide.lock b/glide.lock index 9b906a3..fb52488 100644 --- a/glide.lock +++ b/glide.lock @@ -21,7 +21,7 @@ imports: - name: github.com/coryb/kingpeon version: 9b3d033f8a17e6b66af6123ec776bd93c19234cb - name: github.com/coryb/oreo - version: b59de1c7ff7fe9e084278487f69a07cb667de9b3 + version: 95687d61c95ee1522c1140e2af59b0c1846abfc1 - name: github.com/fatih/camelcase version: f6a740d52f961c60348ebb109adde9f4635d7540 - name: github.com/guelfey/go.dbus diff --git a/vendor/github.com/coryb/oreo/oreo.go b/vendor/github.com/coryb/oreo/oreo.go index 057a05d..b8f12fb 100644 --- a/vendor/github.com/coryb/oreo/oreo.go +++ b/vendor/github.com/coryb/oreo/oreo.go @@ -195,13 +195,11 @@ func (c *Client) saveCookies(resp *http.Response) error { cookies := resp.Cookies() for _, cookie := range cookies { - if cookie.Domain == "" { - // if it is host:port then we need to split off port - parts := strings.Split(resp.Request.URL.Host, ":") - host := parts[0] - log.Debugf("Setting DOMAIN to %s for Cookie: %s", host, cookie) - cookie.Domain = host - } + // if it is host:port then we need to split off port + parts := strings.Split(resp.Request.URL.Host, ":") + host := parts[0] + log.Debugf("Setting DOMAIN to %s for Cookie: %s", host, cookie) + cookie.Domain = host } // expiry in one week from now @@ -304,12 +302,13 @@ func (c *Client) Do(req *http.Request) (resp *http.Response, err error) { // Callback may want to resubmit the request, so we // will need to rewind (Seek) the Reader back to start. + var bodyCache []byte if len(c.postCallbacks) > 0 && !c.handlingPostCallback && req.Body != nil { - bites, err := ioutil.ReadAll(req.Body) + bodyCache, err = ioutil.ReadAll(req.Body) if err != nil { return nil, err } - req.Body = ioutil.NopCloser(bytes.NewReader(bites)) + req.Body = ioutil.NopCloser(bytes.NewReader(bodyCache)) } log.Debugf("%s %s", req.Method, req.URL.String()) @@ -345,11 +344,8 @@ func (c *Client) Do(req *http.Request) (resp *http.Response, err error) { } if len(c.postCallbacks) > 0 && !c.handlingPostCallback { - if req.Body != nil { - rs, ok := req.Body.(io.ReadSeeker) - if ok { - rs.Seek(0, 0) - } + if len(bodyCache) > 0 { + req.Body = ioutil.NopCloser(bytes.NewReader(bodyCache)) } c.handlingPostCallback = true defer func() {