@@ -38,6 +38,7 @@ func TestGet(t *testing.T) {
3838
3939 assertError (t , err )
4040 assertEqual (t , http .StatusOK , resp .StatusCode ())
41+ assertEqual (t , "HTTP/1.1" , resp .Proto ())
4142 assertEqual (t , "200 OK" , resp .Status ())
4243 assertNotNil (t , resp .Body ())
4344 assertEqual (t , "TestGet: text response" , resp .String ())
@@ -56,6 +57,7 @@ func TestGetCustomUserAgent(t *testing.T) {
5657
5758 assertError (t , err )
5859 assertEqual (t , http .StatusOK , resp .StatusCode ())
60+ assertEqual (t , "HTTP/1.1" , resp .Proto ())
5961 assertEqual (t , "200 OK" , resp .Status ())
6062 assertEqual (t , "TestGet: text response" , resp .String ())
6163
@@ -80,6 +82,7 @@ func TestGetClientParamRequestParam(t *testing.T) {
8082
8183 assertError (t , err )
8284 assertEqual (t , http .StatusOK , resp .StatusCode ())
85+ assertEqual (t , "HTTP/1.1" , resp .Proto ())
8386 assertEqual (t , "200 OK" , resp .Status ())
8487 assertEqual (t , "TestGet: text response" , resp .String ())
8588
@@ -825,20 +828,8 @@ func TestGetWithCookies(t *testing.T) {
825828 ts := createGetServer (t )
826829 defer ts .Close ()
827830
828- cookies := []* http.Cookie {
829- {
830- Name : "go-resty-1" ,
831- Value : "This is cookie 1 value" ,
832- },
833- {
834- Name : "go-resty-2" ,
835- Value : "This is cookie 2 value" ,
836- },
837- }
838-
839831 c := dc ()
840- c .SetHostURL (ts .URL ).
841- SetCookies (cookies )
832+ c .SetHostURL (ts .URL ).SetDebug (true )
842833
843834 tu , _ := url .Parse (ts .URL )
844835 c .GetClient ().Jar .SetCookies (tu , []* http.Cookie {
@@ -852,10 +843,26 @@ func TestGetWithCookies(t *testing.T) {
852843 },
853844 })
854845
855- resp , err := c .R ().
856- SetCookie (& http.Cookie {
846+ resp , err := c .R ().SetHeader ("Cookie" , "" ).Get ("mypage2" )
847+ assertError (t , err )
848+ assertEqual (t , http .StatusOK , resp .StatusCode ())
849+
850+ // Client cookies
851+ c .SetCookies ([]* http.Cookie {
852+ {
857853 Name : "go-resty-1" ,
858- Value : "This is cookie 1 value additional append" ,
854+ Value : "This is cookie 1 value" ,
855+ },
856+ {
857+ Name : "go-resty-2" ,
858+ Value : "This is cookie 2 value" ,
859+ },
860+ })
861+
862+ resp , err = c .R ().
863+ SetCookie (& http.Cookie {
864+ Name : "req-go-resty-1" ,
865+ Value : "This is request cookie 1 value additional append" ,
859866 }).
860867 Get ("mypage2" )
861868
@@ -952,7 +959,8 @@ func TestHTTPAutoRedirectUpTo10(t *testing.T) {
952959
953960 _ , err := dc ().R ().Get (ts .URL + "/redirect-1" )
954961
955- assertEqual (t , "Get /redirect-11: stopped after 10 redirects" , err .Error ())
962+ assertEqual (t , true , ("Get /redirect-11: stopped after 10 redirects" == err .Error () ||
963+ "Get \" /redirect-11\" : stopped after 10 redirects" == err .Error ()))
956964}
957965
958966func TestHostCheckRedirectPolicy (t * testing.T ) {
@@ -1119,11 +1127,13 @@ func TestGetClient(t *testing.T) {
11191127func TestIncorrectURL (t * testing.T ) {
11201128 c := dc ()
11211129 _ , err := c .R ().Get ("//not.a.user@%66%6f%6f.com/just/a/path/also" )
1122- assertEqual (t , true , strings .Contains (err .Error (), "parse //not.a.user@%66%6f%6f.com/just/a/path/also" ))
1130+ assertEqual (t , true , (strings .Contains (err .Error (), "parse //not.a.user@%66%6f%6f.com/just/a/path/also" ) ||
1131+ strings .Contains (err .Error (), "parse \" //not.a.user@%66%6f%6f.com/just/a/path/also\" " )))
11231132
11241133 c .SetHostURL ("//not.a.user@%66%6f%6f.com" )
11251134 _ , err1 := c .R ().Get ("/just/a/path/also" )
1126- assertEqual (t , true , strings .Contains (err1 .Error (), "parse //not.a.user@%66%6f%6f.com/just/a/path/also" ))
1135+ assertEqual (t , true , (strings .Contains (err1 .Error (), "parse //not.a.user@%66%6f%6f.com/just/a/path/also" ) ||
1136+ strings .Contains (err1 .Error (), "parse \" //not.a.user@%66%6f%6f.com/just/a/path/also\" " )))
11271137}
11281138
11291139func TestDetectContentTypeForPointer (t * testing.T ) {
0 commit comments