Header correlation using Reg Expressions

jesantosjesantos Posts: 3

I need to send response based on the incoming request header, response will be different based on the first letter of the header value

I tried correlating headers in my responder and used values as: A*, B* and C* but I found that the only Regular expression allowed is for any header "[*]", seems I cannot use my own, is there a way I can correlate the header as needed?

Comments

  • benken_parasoftbenken_parasoft Posts: 773 ✭✭✭

    You probably need to use the "Custom" correlation option. There are examples in the docs, including a regular expression example. The incoming request headers are available using context.get(CorrelationScriptingHookConstants.HEADERS) which returns a Map. So, your code would contain something like this (Groovy):

    Map<String, String> headers = context.get(CorrelationScriptingHookConstants.HEADERS)
    String myHeaderValue = headers.get("headerName")
    return myHeaderValue.matches("A.*")
    
Sign In or Register to comment.