diff --git a/config/components/request/model.go b/config/components/request/model.go index 87ce7fb3..76e9e512 100644 --- a/config/components/request/model.go +++ b/config/components/request/model.go @@ -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 } diff --git a/request/interface.go b/request/interface.go index ca7d50a6..180953c0 100644 --- a/request/interface.go +++ b/request/interface.go @@ -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