Skip to content

Commit

Permalink
Package Request:
Browse files Browse the repository at this point in the history
- fix bug with nil instance thant implement HTTPCLient interface
- fix following code in config/component/request
  • Loading branch information
nabbar committed Feb 20, 2024
1 parent 1d18fbf commit 9b350cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/components/request/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func (o *componentRequest) setRequest(req libreq.Request) {

func (o *componentRequest) getClient() libhtc.HttpClient {
if i := o.c.Load(); i == nil {
return nil
return libhtc.GetClient()
} else if v, k := i.(libhtc.HttpClient); !k {
return nil
return libhtc.GetClient()
} else {
return v
}
Expand Down
6 changes: 5 additions & 1 deletion request/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ func New(ctx libctx.FuncContext, opt *Options, cli libhtc.HttpClient) (Request,
c: new(atomic.Value),
}

r.c.Store(cli)
if cli != nil {
r.c.Store(cli)
} else {
r.c.Store(libhtc.GetClient())
}

if e := r.SetOption(opt); e != nil {
return nil, e
Expand Down

0 comments on commit 9b350cb

Please sign in to comment.