apache httpclient 4.x - Handle Circular redirect using Rest Assured -


i trying send request method 1 of our product api. url needs site minder authentication , redirects requested target.

i can able response setting circular redirect true using apache http client. code looks this

httpclient client = new defaulthttpclient(); httpget = new httpget(url);     client.getparams().setparameter(clientpnames.allow_circular_redirects, true);     get.setheader("authorization", "basic "+encodedauth );     httpresponse response = c.execute(get); 

how work rest assured library ?

tried below getting

caused by: org.apache.http.client.circularredirectexception: circular redirect to

code :

`//restassuredconfig.config().getredirectconfig().followredirects(true).allowcircularredirects(true);` restassuredconfig.newconfig().gethttpclientconfig().setparam("http.protocol.allow-circular-redirects", true);     response r = given().header("authorization", "basic " + encodedauth).get(             url); 

restassuredconfig immutable should this:

restassured.config = restassured.config().httpclientconfig(httpclientconfig().setparam("http.protocol.allow-circular-redirects", true)); 

this apply configuration of requests. if want apply single or selected requests can (i'm trowing in preemptive basic auth here don't manually have set authorization header):

restassuredconfig cfg = restassuredconfig.newconfig().httpclientconfig(httpclientconfig().setparam("http.protocol.allow-circular-redirects", true)); response r = given().config(cfg).auth().preemptive().basic("username", "password").get(url); 

there's redirect dsl simplifies this. ought instead of setting property manually:

response r =  given().         redirects().allowcircular(true).         auth().preemptive().basic("username", "password"). when().         get(url); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -