@@ -55,9 +55,10 @@ type Client struct {
5555 userResponseHooks []ResponseHook
5656 builtinResponseHooks []ResponseHook
5757
58- timeout time.Duration
59- mu sync.RWMutex
60- debug bool
58+ timeout time.Duration
59+ mu sync.RWMutex
60+ debug bool
61+ disablePathNormalizing bool
6162}
6263
6364// R creates a new Request associated with the client.
@@ -353,6 +354,17 @@ func (c *Client) SetReferer(r string) *Client {
353354 return c
354355}
355356
357+ // DisablePathNormalizing reports whether path normalizing is disabled for the client.
358+ func (c * Client ) DisablePathNormalizing () bool {
359+ return c .disablePathNormalizing
360+ }
361+
362+ // SetDisablePathNormalizing configures the client to disable or enable path normalizing.
363+ func (c * Client ) SetDisablePathNormalizing (disable bool ) * Client {
364+ c .disablePathNormalizing = disable
365+ return c
366+ }
367+
356368// PathParam returns the value of the specified path parameter. Returns an empty string if it does not exist.
357369func (c * Client ) PathParam (key string ) string {
358370 if val , ok := (* c .path )[key ]; ok {
@@ -529,6 +541,7 @@ func (c *Client) Reset() {
529541 c .referer = ""
530542 c .retryConfig = nil
531543 c .debug = false
544+ c .disablePathNormalizing = false
532545
533546 if c .cookieJar != nil {
534547 c .cookieJar .Release ()
@@ -545,18 +558,19 @@ func (c *Client) Reset() {
545558// JSON is used as the default serialization mechanism. The priority is:
546559// Body > FormData > File.
547560type Config struct {
548- Ctx context.Context //nolint:containedctx // It's needed to be stored in the config.
549- Body any
550- Header map [string ]string
551- Param map [string ]string
552- Cookie map [string ]string
553- PathParam map [string ]string
554- FormData map [string ]string
555- UserAgent string
556- Referer string
557- File []* File
558- Timeout time.Duration
559- MaxRedirects int
561+ Ctx context.Context //nolint:containedctx // It's needed to be stored in the config.
562+ Body any
563+ Header map [string ]string
564+ Param map [string ]string
565+ Cookie map [string ]string
566+ PathParam map [string ]string
567+ FormData map [string ]string
568+ UserAgent string
569+ Referer string
570+ File []* File
571+ Timeout time.Duration
572+ MaxRedirects int
573+ DisablePathNormalizing bool
560574}
561575
562576// setConfigToRequest sets the parameters passed via Config to the Request.
@@ -602,6 +616,10 @@ func setConfigToRequest(req *Request, config ...Config) {
602616 req .SetMaxRedirects (cfg .MaxRedirects )
603617 }
604618
619+ if cfg .DisablePathNormalizing {
620+ req .SetDisablePathNormalizing (true )
621+ }
622+
605623 if cfg .Body != nil {
606624 req .SetJSON (cfg .Body )
607625 return
0 commit comments