Skip to content

Commit

Permalink
refactor: unify the entry to set request options
Browse files Browse the repository at this point in the history
  • Loading branch information
Duslia committed Jun 16, 2022
1 parent ce28dd9 commit d2d9a28
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/protocol/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (w *requestBodyWriter) Write(p []byte) (int, error) {
}

func (req *Request) Options() *config.RequestOptions {
if req.options == nil {
req.options = config.NewRequestOptions(nil)
}
return req.options
}

Expand Down Expand Up @@ -784,11 +787,7 @@ func (req *Request) QueryString() []byte {
// SetOptions is used to set request options.
// These options can be used to do something in middlewares such as service discovery.
func (req *Request) SetOptions(opts ...config.RequestOption) {
if req.options == nil {
req.options = config.NewRequestOptions(opts)
} else {
req.options.Apply(opts)
}
req.Options().Apply(opts)
}

// ConnectionClose returns true if 'Connection: close' header is set.
Expand Down

0 comments on commit d2d9a28

Please sign in to comment.