Skip to content

Commit

Permalink
fix: fix nil exception
Browse files Browse the repository at this point in the history
  • Loading branch information
medcl committed Jul 9, 2024
1 parent 3b70fc7 commit 00f15fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,20 @@ type RunnerConfig struct {
}

func (config *RunnerConfig) parseDefaultEndpoint() (*fasthttp.URI, error) {
if config.defaultEndpoint != nil {
return config.defaultEndpoint, nil
}

if config.DefaultEndpoint != "" {
config.defaultEndpoint = &fasthttp.URI{}
err := config.defaultEndpoint.Parse(nil, []byte(config.DefaultEndpoint))
uri := &fasthttp.URI{}
err := uri.Parse(nil, []byte(config.DefaultEndpoint))
if err != nil {
return nil, err
}
config.defaultEndpoint = uri
return config.defaultEndpoint, err
}

if config.defaultEndpoint != nil {
return config.defaultEndpoint, nil
}

return config.defaultEndpoint, errors.New("no valid default endpoint")
}

Expand Down
5 changes: 5 additions & 0 deletions loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func doRequest(config *LoaderConfig,globalCtx util.MapStr,req *fasthttp.Request,
err = httpClient.Do(req, resp)
}

if global.Env().IsDebug{
log.Info(resp.String())
}

duration:=time.Since(start)
statsCode:=resp.StatusCode()

Expand Down Expand Up @@ -376,6 +380,7 @@ func (v *RequestItem) prepareRequest(config *LoaderConfig, globalCtx util.MapStr
}
if parsedUrl.Host() == nil || len(parsedUrl.Host()) == 0 {
path,err:=config.RunnerConfig.parseDefaultEndpoint()
//log.Infof("default endpoint: %v, %v",path,err)
if err==nil{
parsedUrl.SetSchemeBytes(path.Scheme())
parsedUrl.SetHostBytes(path.Host())
Expand Down

0 comments on commit 00f15fd

Please sign in to comment.