@@ -744,3 +744,46 @@ func TestResponseError(t *testing.T) {
744744 assertNotNil (t , re .Unwrap ())
745745 assertEqual (t , err .Error (), re .Error ())
746746}
747+
748+ func TestHostURLForGH318AndGH407 (t * testing.T ) {
749+ ts := createPostServer (t )
750+ defer ts .Close ()
751+
752+ targetURL , _ := url .Parse (ts .URL )
753+ t .Log ("ts.URL:" , ts .URL )
754+ t .Log ("targetURL.Host:" , targetURL .Host )
755+ // Sample output
756+ // ts.URL: http://127.0.0.1:55967
757+ // targetURL.Host: 127.0.0.1:55967
758+
759+ // Unable use the local http test server for this
760+ // use case testing
761+ //
762+ // using `targetURL.Host` value or test case yield to ERROR
763+ // "parse "127.0.0.1:55967": first path segment in URL cannot contain colon"
764+
765+ // test the functionality with httpbin.org locally
766+ // will figure out later
767+
768+ c := dc ()
769+ // c.SetScheme("http")
770+ // c.SetHostURL(targetURL.Host + "/")
771+
772+ // t.Log("with leading `/`")
773+ // resp, err := c.R().Post("/login")
774+ // assertNil(t, err)
775+ // assertNotNil(t, resp)
776+
777+ // t.Log("\nwithout leading `/`")
778+ // resp, err = c.R().Post("login")
779+ // assertNil(t, err)
780+ // assertNotNil(t, resp)
781+
782+ t .Log ("with leading `/` on request & with trailing `/` on host url" )
783+ c .SetHostURL (ts .URL + "/" )
784+ resp , err := c .R ().
785+ SetBody (map [string ]interface {}{"username" : "testuser" , "password" : "testpass" }).
786+ Post ("/login" )
787+ assertNil (t , err )
788+ assertNotNil (t , resp )
789+ }
0 commit comments