cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep request header during redirect scenario?

Contributor

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)") 

 

TIM截图20190617183831.png

 

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-fo...

5 REPLIES 5
Community Hero

Re: How to keep request header during redirect scenario?

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

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Contributor

Re: How to keep request header during redirect scenario?

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)

 

Snipaste_2019-06-18_11-22-45.png

 

Highlighted
Contributor

Re: How to keep request header during redirect scenario?

Access http://www.bing.com as example, when I try to access http://www.bing.com, it will redirect to https://cn.bing.com

 

Here is the screenshots with Fiddler and SoapUI Pro:

 

GET http://www.bing.com/ HTTP/1.1


purpose: preview
x-purpose: preview
x-moz: preview
Host: www.bing.com
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

 

TIM截图20190618120748.png

 

Community Hero

Re: How to keep request header during redirect scenario?

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

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Community Manager

Re: How to keep request header during redirect scenario?

Hi @白夜有点黑,

 

In ReadyAPI, we have two options to handle redirects: 

Follow Redirects

If true, the request will follow the redirect and return the server message. Otherwise, a redirect message will be returned.

Follow 302 Redirect with GET

If true, Ready! API uses the GET method for subsequent requests if the response has the 302 Found HTTP code.

 

Please refer to the following articles to learn more: https://support.smartbear.com/readyapi/docs/projects/ui/request-properties/rest.html

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Top Kudoed Authors