File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -2193,7 +2193,11 @@ func (c *Client) Clone(ctx context.Context) *Client {
2193
2193
cc .formData = cloneURLValues (c .formData )
2194
2194
cc .header = c .header .Clone ()
2195
2195
cc .pathParams = maps .Clone (c .pathParams )
2196
- cc .credentials = c .credentials .Clone ()
2196
+
2197
+ if c .credentials != nil {
2198
+ cc .credentials = c .credentials .Clone ()
2199
+ }
2200
+
2197
2201
cc .contentTypeEncoders = maps .Clone (c .contentTypeEncoders )
2198
2202
cc .contentTypeDecoders = maps .Clone (c .contentTypeDecoders )
2199
2203
cc .contentDecompressers = maps .Clone (c .contentDecompressers )
Original file line number Diff line number Diff line change @@ -363,14 +363,15 @@ func (es *EventSource) Get() error {
363
363
if isStringEmpty (es .url ) {
364
364
return fmt .Errorf ("resty:sse: event source URL is required" )
365
365
}
366
+
366
367
if isStringEmpty (es .method ) {
367
368
// It is up to the user to choose which http method to use, depending on the specific code implementation. No restrictions are imposed here.
368
369
// Ensure compatibility, use GET as default http method
369
370
es .method = defaultHTTPMethod
370
371
}
371
372
372
- if _ , found := es .onEvent [ defaultEventName ]; ! found {
373
- return fmt .Errorf ("resty:sse: OnMessage function is required" )
373
+ if len ( es .onEvent ) == 0 {
374
+ return fmt .Errorf ("resty:sse: At least one OnMessage/AddEventListener func is required" )
374
375
}
375
376
376
377
// reset to begin
Original file line number Diff line number Diff line change @@ -341,7 +341,7 @@ func TestEventSourceCoverage(t *testing.T) {
341
341
342
342
es .SetURL ("https://sse.dev/test" )
343
343
err2 := es .Get ()
344
- assertEqual (t , "resty:sse: OnMessage function is required" , err2 .Error ())
344
+ assertEqual (t , "resty:sse: At least one OnMessage/AddEventListener func is required" , err2 .Error ())
345
345
346
346
es .OnMessage (func (a any ) {}, nil )
347
347
es .SetURL ("//res%20ty.dev" )
You can’t perform that action at this time.
0 commit comments