Asking about redirections

Hello lads, hope everyone is doing okay…

I have this problem with my company website, I’m gonna explain:

The first request is a head request i use it to get the url in Location but the thing is sometimes the request gives me the correct url sometimes it goes to an intermediate request i should call it too to get my final url, to understand it better check the code below

Sometimes calling " First Head " gives me directly " Final Stage " but sometimes i have to pass the " Visiting Location1 " to get to it.

So what’s the best solution for this

@Ruri

Thanks for helping

LABEL:First Head
  method = HEAD
  autoRedirect = False
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Parse
LABEL:Location1
  input = @data.HEADERS["Location"]
  MODE:LR
  => VAR @Location1
ENDBLOCK

BLOCK:HttpRequest
LABEL:Visiting Location1
  url = @Location1
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Parse
LABEL:Location2
  input = @data.HEADERS["Location"]
  MODE:LR
  => VAR @Location2
ENDBLOCK

BLOCK:HttpRequest
LABEL:Final Stage
  url = $"<Location1> Or <Location2>"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

Well I would use an IF statement to check if the first response has a given header or status code, and then inside the statement I would do the intermediate request.

// First request

IF DICTKEY @data.HEADERS HasKey "Location"
IF STRINGKEY @data.HEADERS["Location"] Contains "url for location 1"
// Intermediate request block here
END
END

// Now you should have the final stage
1 Like