mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
udpate oreo for request replays
This commit is contained in:
+10
-14
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user