Skip to content

Commit af72a4d

Browse files
authored
feat: add server-sent events client #658 (#931)
1 parent 8422694 commit af72a4d

File tree

5 files changed

+1058
-2
lines changed

5 files changed

+1058
-2
lines changed

client.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
ErrUnsupportedRequestBodyKind = errors.New("resty: unsupported request body kind")
5959

6060
hdrUserAgentKey = http.CanonicalHeaderKey("User-Agent")
61+
hdrAcceptKey = http.CanonicalHeaderKey("Accept")
6162
hdrAcceptEncodingKey = http.CanonicalHeaderKey("Accept-Encoding")
6263
hdrContentTypeKey = http.CanonicalHeaderKey("Content-Type")
6364
hdrContentLengthKey = http.CanonicalHeaderKey("Content-Length")

resty_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434

3535
var (
3636
hdrLocationKey = http.CanonicalHeaderKey("Location")
37-
hdrAcceptKey = http.CanonicalHeaderKey("Accept")
3837
)
3938

4039
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

retry.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ func (b *backoffWithJitter) NextWaitDuration(c *Client, res *Response, err error
115115
b.max = maxInt
116116
}
117117

118-
retryStrategyFunc := c.RetryStrategy()
118+
var retryStrategyFunc RetryStrategyFunc
119+
if c != nil {
120+
retryStrategyFunc = c.RetryStrategy()
121+
}
119122
if res == nil || retryStrategyFunc == nil {
120123
return b.balanceMinMax(b.defaultStrategy(attempt)), nil
121124
}

0 commit comments

Comments
 (0)