Ask a Question

How to retrieve a value from the request header?

SOLVED
senthkum
Contributor

How to retrieve a value from the request header?

Hi All, 

 

I am New to Groovy Scripting, I need to get the value of Host from the header (highlighted in bold), I tried the below code but it did not work. Could someone help me in fixing below code.

 

Code:

----------

def getHost = mockRequest.getRequestHeaders().get("Host")

if( getHost.contains("wbmgwy1-sit1.metest.local"))
{
// return the name of the response you want to dispatch
return "L-Env-Response"
}
else if( getHost.contains("virinf0002vt.metest.local"))
{
// return the name of the response you want to dispatch
return "U-Env-Response"
}

Header:

-----------

POST /ArrangementService HTTP/1.1

Connection: keep-alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Host: virinf0002vt.metest.local:8081

Accept-Encoding: gzip,deflate

Content-Length: 1629

Content-Type: application/soap+xml;charset=UTF-8;action="MEB_AS_ArM_ArrangementES_WS_provider_v3_ArrangementService_Binder_getArrangementList"

 

Thanks and Regards

-------------------------

Senthil kumar. M

 

 

2 REPLIES 2
AlexKaras
Community Hero

Hi,

 

> but it did not work.

More details, please?

 

> help me in fixing below code.

What exactly needs to be fixed?

 

Does this help: https://community.smartbear.com/t5/SoapUI-Pro/How-to-get-header-data-from-a-RAW-response-into-a-para... ?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

HI Alex,

 

Thanks for your support, the documnet provided was helpfull to me. 

 

Regards

Senthil kumar. M

cancel
Showing results for 
Search instead for 
Did you mean: