Forum Discussion

白夜有点黑's avatar
白夜有点黑
Contributor
5 years ago

How to keep request header during redirect scenario?

I have below sites, and when access to site1 it will redirect to site2:

 

(Note: below sites are all fake and just showed as a demo)

site1: http://www.test.com/test?a=1

site2: http://www.test.com/test?a=1&_z=_

 

Tried with Fiddler (site1 and site2 has the same request header during redirect action, which is expected result):

GET http://www.test.com/test?a=1

User-Agent: Fiddler
Purpose: prefetch
Host: www.test.com

 

GET http://www.test.com/test?a=1&_z=_

User-Agent: Fiddler
Purpose: prefetch
Host: www.test.com

 

 

But when I tried it with Soapui Pro, it shows as below:

GET http://www.test.com/test?a=1

User-Agent: Fiddler
Purpose: prefetch
Host: www.test.com

 

GET http://www.test.com/test?a=1&_z=_

User-Agent: Fiddler
Host: www.test.com

 

As you can see, the header "Purpose: prefetch" is gone after the redirect action,  which is not expect result. How to handle this and make it works just like Fiddler did?

 

Besides, this issue also happened with Useragent setting, if you setting your custom useragent with "Preferences -> HTTP Setting -> User-Agent Header", it's only works with the first request url, the redirect sites always used the default useragent value ("User-Agent: Apache-HttpClient/4.1.1 (java 1.5)") 

 

 

I already blocked with this issue, please help to have a look, thanks.

 

 

And there's another related issue here: https://community.smartbear.com/t5/SoapUI-Open-Source/Wrong-redirect-in-HTTP-request-with-several-following-redirects/td-p/109555

5 Replies

  • richie's avatar
    richie
    Community Hero

    Hey 白夜有点黑 

     

    I don't think I'll be much help on this - but firstly is this a custom header?  in the details below - you represent the header and value as 'Purpose: Prefetch' - but I know there is already a 'Prefetch' http header - but there isn't a standard one known as 'Purpose' - can  you clarify what you mean by 'Purpose: Prefetch'?

     

    You haven't supplied a list of the other headers in your requests - the values of some of the other headers 'could' be impacting other headers - especially custom ones - could you list out all the headers for both the fiddler and soapui requests - perhaps a screenshot?

     

    nmrao responded to a similar issue several years ago where he manually added a custom User-Agent header in the request (without setting the "User-Agent header" option in the Preferences) - the link is as follows: link - perhaps this will help?

     

     

    ta,

     

    richie

     

    • 白夜有点黑's avatar
      白夜有点黑
      Contributor

      Here is the whole request headers:

       

      Accept-Encoding: gzip,deflate
      purpose: preview
      x-purpose: preview
      x-moz: preview
      Host: www.test.com
      Connection: Keep-Alive
      User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

       

       

      • richie's avatar
        richie
        Community Hero

        Hey 白夜有点黑 

         

        I'm sorry - I don't think I was clear.  you have supplied some screenshots - but I meant multiple screenshots of everything that could provide some info on your request AND your response - both via Postman and ReadyAPI.

         

        What I meant was to compare Postman publishing to site1 and redirecting to site2 whilst proxying the requests with fiddler - grab screenshots of what is detailed in fiddler - RAW, headers and cookies via fiddler and what was in Postman (just to be sure)

         

        Do the exactly the same for ReadyAPI! - and then see what is different.  From what you've stated, the requests are being treated differently - i.e. missing custom headers when submitting the request via ReadyAPI! - we know the app server is treating the requests from ReadyAPI! differently to the ones from Postman (quite often I've noticed this and "I think" this is cos a lot of stuff is enabled by default in Postman, but ReadyAPI! is far more configurable) we need to try and identify the difference to determine the cause of the missing headers.

         

        Another thing - what do your custom headers do?  as I said before - headers can interfer with the desired behaviour - so it might add some value to explain what your headers actually do (although I dont think much of this idea to be honest - you have so few headers I cant really see a problem there).

         

        ta

         

        richie