Forum Discussion

Mason's avatar
Mason
Frequent Contributor
15 years ago

[RESOLVED] Apply headers globally?

At the Suite or Test Case level, is it possible to apply/insert headers for each Test Step (request).  As it looks now, it appears I have to manually insert a header for each step.  It would be a lot easier if there was a way to specify a header and a value and apply it to the entire range of requests within the test case or test suite.  Is this possible?

Thanks,
Mason

9 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Mason,

    easiest would probably to create a RequestFilter.filterRequest Event Handler (in the Project windows Handlers tab) that adds the header dynamically to each outgoing request.. do you want me to prepare an example for you?

    regards!

    /Ole
    eviware.com
  • Mason's avatar
    Mason
    Frequent Contributor
    I don't see a "Handlers tab" from the Project context so I guess I'm going to need an example.

    Cheers,
    Mason
  • Mason's avatar
    Mason
    Frequent Contributor
    Yep, using the nightly build from 08/12/2009
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    I believe Ole is thinking on Events tab in project window. Check, please.

    robert
  • Mason's avatar
    Mason
    Frequent Contributor
    Yes, I see that...and I see the choice for RequestFilter.filterRequest but I'm not really sure how this would be used or implemented.  Any examples would be helpful.

    Thanks,
    Mason
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Check: http://www.soapui.org/userguide/project ... dlers.html

    As you can see for each event handler you add a groovy script that do something. If your script look something like this:


    def post = context.getProperty("postMethod")
    post.setRequestHeader("Test", "Hello")  <-- adding header
    for ( h in post.getRequestHeaders() )
      log.info( h )                                          <-- list all my headers




    Does it help,

    robert
  • Mason's avatar
    Mason
    Frequent Contributor
    It most definitely helps.  We'll give this a shot.

    Cheers,
    Mason