You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by Aaron Hamid <ar...@cornell.edu> on 2003/09/15 18:19:39 UTC

manipulating headers in pre-processor

Hi, I have written a pre-processor that modifies headers on an HTTPSampler (I need to do this because the header is dynamically derived), but the call getHeaderManager() on the HTTPSampler object always returns null.  Even if I have actually created a HeaderManager in the test configuration.  Creating a new HeaderManager object and programmatically calling setHeaderManager on the HTTPSampler object in my preprocessor doesn't do anything either.  Is there a way to dynamically modify outgoing request headers?

Aaron Hamid
CIT/I&D


Re: manipulating headers in pre-processor

Posted by ar...@cornell.edu.
Ok, I moved the manager.add(header) call up above 
sampler.setHeaderManager() to ensure that the manager being set in fact 
has at least one header already in it.  The manager object subsequently 
retrieved is indeed the same object (object hashcode) that was set (I 
checked just for sanity).  But the header is still not coming through.  
Next step is rebuilding JMeter with some extra debugging I suppose.

Aaron

On Tue, 16 Sep 2003 mstover1@apache.org wrote:

> Ah, that helps greatly.
> 
> 
> try putting the headers into the manager and then calling 
> sampler.setHeaderManager(manager).  JMeter is doing lots of funky things 
> during test runs.  In essense, it's searching your header manager for headers 
> and finds none, so it gets tossed.  It does this because values from multiple 
> headers potentially have to be merged (in a certain order) and the sampler 
> has to be returned to original condition after each run - all without cloning 
> objects all over the place.
> 
> -Mike
> 
> On 16 Sep 2003 at 8:52, Aaron Hamid wrote:
> 
> > It's not.
> > 
> > public void process() {
> >   ...
> > 
> >   Header header = new Header("Authorization", authstring);
> >   HeaderManager manager = sampler.getHeaderManager();
> >   if (manager != null) {
> >     manager.add(header);
> >   } else {
> >     log.error("No header manager configured for sampler: " + sampler);
> >     manager = new HeaderManager();
> >     sampler.setHeaderManager(manager);
> >     manager.add(header);
> >     System.out.println("manager size: " + manager.size());
> >     for (int i = 0; i < manager.size(); i++) {
> >       System.out.println("header: " + manager.get(i));
> >     }
> >     System.out.println("manager: " + sampler.getHeaderManager());
> >   }
> > 
> > My header is indeed in the manager as the loop proves, but it is not 
> coming out in the request (although I can see the fixed user-agent header I 
> set through a HeaderManager GUI).  Can anybody else verify this?  (I tried 
> with a header named something other than "Authorization" just in case, and it 
> doesn't come through either)
> > 
> > Aaron
> > 
> > 
> > mstover1@apache.org wrote:
> > 
> > > Making a new HeaderManager and calling setHeaderManager 
> > > ought to work.
> > > 
> > > -Mike
> > > 
> > > On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> > > 
> > > 
> > >>Hi, I have written a pre-processor that modifies headers on an 
> HTTPSampler (I need to do this because the header is dynamically derived), 
> but the call getHeaderManager() on the HTTPSampler object always returns 
> null.  Even if I have actually created a HeaderManager in the test 
> configuration.  Creating a new HeaderManager object and programmatically 
> calling setHeaderManager on the HTTPSampler object in my preprocessor 
> doesn't do anything either.  Is there a way to dynamically modify outgoing 
> request headers?
> > >>
> > >>Aaron Hamid
> > >>CIT/I&D
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: jmeter-dev-
> > > 
> > > unsubscribe@jakarta.apache.org
> > > 
> > >>For additional commands, e-mail: jmeter-dev-
> > > 
> > > help@jakarta.apache.org
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > Michael Stover
> > > mstover1@apache.org
> > > Yahoo IM: mstover_ya
> > > ICQ: 152975688
> > > AIM: mstover777
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > 
> 
> 
> 
> 
> --
> Michael Stover
> mstover1@apache.org
> Yahoo IM: mstover_ya
> ICQ: 152975688
> AIM: mstover777
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Re: manipulating headers in pre-processor

Posted by ar...@cornell.edu.
Ok, I moved the manager.add(header) call up above 
sampler.setHeaderManager() to ensure that the manager being set in fact 
has at least one header already in it.  The manager object subsequently 
retrieved is indeed the same object (object hashcode) that was set (I 
checked just for sanity).  But the header is still not coming through.  
Next step is rebuilding JMeter with some extra debugging I suppose.

Aaron

On Tue, 16 Sep 2003 mstover1@apache.org wrote:

> Ah, that helps greatly.
> 
> 
> try putting the headers into the manager and then calling 
> sampler.setHeaderManager(manager).  JMeter is doing lots of funky things 
> during test runs.  In essense, it's searching your header manager for headers 
> and finds none, so it gets tossed.  It does this because values from multiple 
> headers potentially have to be merged (in a certain order) and the sampler 
> has to be returned to original condition after each run - all without cloning 
> objects all over the place.
> 
> -Mike
> 
> On 16 Sep 2003 at 8:52, Aaron Hamid wrote:
> 
> > It's not.
> > 
> > public void process() {
> >   ...
> > 
> >   Header header = new Header("Authorization", authstring);
> >   HeaderManager manager = sampler.getHeaderManager();
> >   if (manager != null) {
> >     manager.add(header);
> >   } else {
> >     log.error("No header manager configured for sampler: " + sampler);
> >     manager = new HeaderManager();
> >     sampler.setHeaderManager(manager);
> >     manager.add(header);
> >     System.out.println("manager size: " + manager.size());
> >     for (int i = 0; i < manager.size(); i++) {
> >       System.out.println("header: " + manager.get(i));
> >     }
> >     System.out.println("manager: " + sampler.getHeaderManager());
> >   }
> > 
> > My header is indeed in the manager as the loop proves, but it is not 
> coming out in the request (although I can see the fixed user-agent header I 
> set through a HeaderManager GUI).  Can anybody else verify this?  (I tried 
> with a header named something other than "Authorization" just in case, and it 
> doesn't come through either)
> > 
> > Aaron
> > 
> > 
> > mstover1@apache.org wrote:
> > 
> > > Making a new HeaderManager and calling setHeaderManager 
> > > ought to work.
> > > 
> > > -Mike
> > > 
> > > On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> > > 
> > > 
> > >>Hi, I have written a pre-processor that modifies headers on an 
> HTTPSampler (I need to do this because the header is dynamically derived), 
> but the call getHeaderManager() on the HTTPSampler object always returns 
> null.  Even if I have actually created a HeaderManager in the test 
> configuration.  Creating a new HeaderManager object and programmatically 
> calling setHeaderManager on the HTTPSampler object in my preprocessor 
> doesn't do anything either.  Is there a way to dynamically modify outgoing 
> request headers?
> > >>
> > >>Aaron Hamid
> > >>CIT/I&D
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: jmeter-dev-
> > > 
> > > unsubscribe@jakarta.apache.org
> > > 
> > >>For additional commands, e-mail: jmeter-dev-
> > > 
> > > help@jakarta.apache.org
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > Michael Stover
> > > mstover1@apache.org
> > > Yahoo IM: mstover_ya
> > > ICQ: 152975688
> > > AIM: mstover777
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > 
> 
> 
> 
> 
> --
> Michael Stover
> mstover1@apache.org
> Yahoo IM: mstover_ya
> ICQ: 152975688
> AIM: mstover777
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 
> 

Re: manipulating headers in pre-processor

Posted by ms...@apache.org.
Ah, that helps greatly.


try putting the headers into the manager and then calling 
sampler.setHeaderManager(manager).  JMeter is doing lots of funky things 
during test runs.  In essense, it's searching your header manager for headers 
and finds none, so it gets tossed.  It does this because values from multiple 
headers potentially have to be merged (in a certain order) and the sampler 
has to be returned to original condition after each run - all without cloning 
objects all over the place.

-Mike

On 16 Sep 2003 at 8:52, Aaron Hamid wrote:

> It's not.
> 
> public void process() {
>   ...
> 
>   Header header = new Header("Authorization", authstring);
>   HeaderManager manager = sampler.getHeaderManager();
>   if (manager != null) {
>     manager.add(header);
>   } else {
>     log.error("No header manager configured for sampler: " + sampler);
>     manager = new HeaderManager();
>     sampler.setHeaderManager(manager);
>     manager.add(header);
>     System.out.println("manager size: " + manager.size());
>     for (int i = 0; i < manager.size(); i++) {
>       System.out.println("header: " + manager.get(i));
>     }
>     System.out.println("manager: " + sampler.getHeaderManager());
>   }
> 
> My header is indeed in the manager as the loop proves, but it is not 
coming out in the request (although I can see the fixed user-agent header I 
set through a HeaderManager GUI).  Can anybody else verify this?  (I tried 
with a header named something other than "Authorization" just in case, and it 
doesn't come through either)
> 
> Aaron
> 
> 
> mstover1@apache.org wrote:
> 
> > Making a new HeaderManager and calling setHeaderManager 
> > ought to work.
> > 
> > -Mike
> > 
> > On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> > 
> > 
> >>Hi, I have written a pre-processor that modifies headers on an 
HTTPSampler (I need to do this because the header is dynamically derived), 
but the call getHeaderManager() on the HTTPSampler object always returns 
null.  Even if I have actually created a HeaderManager in the test 
configuration.  Creating a new HeaderManager object and programmatically 
calling setHeaderManager on the HTTPSampler object in my preprocessor 
doesn't do anything either.  Is there a way to dynamically modify outgoing 
request headers?
> >>
> >>Aaron Hamid
> >>CIT/I&D
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: jmeter-dev-
> > 
> > unsubscribe@jakarta.apache.org
> > 
> >>For additional commands, e-mail: jmeter-dev-
> > 
> > help@jakarta.apache.org
> > 
> > 
> > 
> > 
> > 
> > --
> > Michael Stover
> > mstover1@apache.org
> > Yahoo IM: mstover_ya
> > ICQ: 152975688
> > AIM: mstover777
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 




--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688
AIM: mstover777

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Re: manipulating headers in pre-processor

Posted by ms...@apache.org.
Ah, that helps greatly.


try putting the headers into the manager and then calling 
sampler.setHeaderManager(manager).  JMeter is doing lots of funky things 
during test runs.  In essense, it's searching your header manager for headers 
and finds none, so it gets tossed.  It does this because values from multiple 
headers potentially have to be merged (in a certain order) and the sampler 
has to be returned to original condition after each run - all without cloning 
objects all over the place.

-Mike

On 16 Sep 2003 at 8:52, Aaron Hamid wrote:

> It's not.
> 
> public void process() {
>   ...
> 
>   Header header = new Header("Authorization", authstring);
>   HeaderManager manager = sampler.getHeaderManager();
>   if (manager != null) {
>     manager.add(header);
>   } else {
>     log.error("No header manager configured for sampler: " + sampler);
>     manager = new HeaderManager();
>     sampler.setHeaderManager(manager);
>     manager.add(header);
>     System.out.println("manager size: " + manager.size());
>     for (int i = 0; i < manager.size(); i++) {
>       System.out.println("header: " + manager.get(i));
>     }
>     System.out.println("manager: " + sampler.getHeaderManager());
>   }
> 
> My header is indeed in the manager as the loop proves, but it is not 
coming out in the request (although I can see the fixed user-agent header I 
set through a HeaderManager GUI).  Can anybody else verify this?  (I tried 
with a header named something other than "Authorization" just in case, and it 
doesn't come through either)
> 
> Aaron
> 
> 
> mstover1@apache.org wrote:
> 
> > Making a new HeaderManager and calling setHeaderManager 
> > ought to work.
> > 
> > -Mike
> > 
> > On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> > 
> > 
> >>Hi, I have written a pre-processor that modifies headers on an 
HTTPSampler (I need to do this because the header is dynamically derived), 
but the call getHeaderManager() on the HTTPSampler object always returns 
null.  Even if I have actually created a HeaderManager in the test 
configuration.  Creating a new HeaderManager object and programmatically 
calling setHeaderManager on the HTTPSampler object in my preprocessor 
doesn't do anything either.  Is there a way to dynamically modify outgoing 
request headers?
> >>
> >>Aaron Hamid
> >>CIT/I&D
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: jmeter-dev-
> > 
> > unsubscribe@jakarta.apache.org
> > 
> >>For additional commands, e-mail: jmeter-dev-
> > 
> > help@jakarta.apache.org
> > 
> > 
> > 
> > 
> > 
> > --
> > Michael Stover
> > mstover1@apache.org
> > Yahoo IM: mstover_ya
> > ICQ: 152975688
> > AIM: mstover777
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 




--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688
AIM: mstover777

Re: manipulating headers in pre-processor

Posted by Aaron Hamid <ar...@cornell.edu>.
It's not.

public void process() {
  ...

  Header header = new Header("Authorization", authstring);
  HeaderManager manager = sampler.getHeaderManager();
  if (manager != null) {
    manager.add(header);
  } else {
    log.error("No header manager configured for sampler: " + sampler);
    manager = new HeaderManager();
    sampler.setHeaderManager(manager);
    manager.add(header);
    System.out.println("manager size: " + manager.size());
    for (int i = 0; i < manager.size(); i++) {
      System.out.println("header: " + manager.get(i));
    }
    System.out.println("manager: " + sampler.getHeaderManager());
  }

My header is indeed in the manager as the loop proves, but it is not coming out in the request (although I can see the fixed user-agent header I set through a HeaderManager GUI).  Can anybody else verify this?  (I tried with a header named something other than "Authorization" just in case, and it doesn't come through either)

Aaron


mstover1@apache.org wrote:

> Making a new HeaderManager and calling setHeaderManager 
> ought to work.
> 
> -Mike
> 
> On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> 
> 
>>Hi, I have written a pre-processor that modifies headers on an HTTPSampler (I need to do this because the header is dynamically derived), but the call getHeaderManager() on the HTTPSampler object always returns null.  Even if I have actually created a HeaderManager in the test configuration.  Creating a new HeaderManager object and programmatically calling setHeaderManager on the HTTPSampler object in my preprocessor doesn't do anything either.  Is there a way to dynamically modify outgoing request headers?
>>
>>Aaron Hamid
>>CIT/I&D
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: jmeter-dev-
> 
> unsubscribe@jakarta.apache.org
> 
>>For additional commands, e-mail: jmeter-dev-
> 
> help@jakarta.apache.org
> 
> 
> 
> 
> 
> --
> Michael Stover
> mstover1@apache.org
> Yahoo IM: mstover_ya
> ICQ: 152975688
> AIM: mstover777
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Re: manipulating headers in pre-processor

Posted by Aaron Hamid <ar...@cornell.edu>.
It's not.

public void process() {
  ...

  Header header = new Header("Authorization", authstring);
  HeaderManager manager = sampler.getHeaderManager();
  if (manager != null) {
    manager.add(header);
  } else {
    log.error("No header manager configured for sampler: " + sampler);
    manager = new HeaderManager();
    sampler.setHeaderManager(manager);
    manager.add(header);
    System.out.println("manager size: " + manager.size());
    for (int i = 0; i < manager.size(); i++) {
      System.out.println("header: " + manager.get(i));
    }
    System.out.println("manager: " + sampler.getHeaderManager());
  }

My header is indeed in the manager as the loop proves, but it is not coming out in the request (although I can see the fixed user-agent header I set through a HeaderManager GUI).  Can anybody else verify this?  (I tried with a header named something other than "Authorization" just in case, and it doesn't come through either)

Aaron


mstover1@apache.org wrote:

> Making a new HeaderManager and calling setHeaderManager 
> ought to work.
> 
> -Mike
> 
> On 15 Sep 2003 at 12:19, Aaron Hamid wrote:
> 
> 
>>Hi, I have written a pre-processor that modifies headers on an HTTPSampler (I need to do this because the header is dynamically derived), but the call getHeaderManager() on the HTTPSampler object always returns null.  Even if I have actually created a HeaderManager in the test configuration.  Creating a new HeaderManager object and programmatically calling setHeaderManager on the HTTPSampler object in my preprocessor doesn't do anything either.  Is there a way to dynamically modify outgoing request headers?
>>
>>Aaron Hamid
>>CIT/I&D
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: jmeter-dev-
> 
> unsubscribe@jakarta.apache.org
> 
>>For additional commands, e-mail: jmeter-dev-
> 
> help@jakarta.apache.org
> 
> 
> 
> 
> 
> --
> Michael Stover
> mstover1@apache.org
> Yahoo IM: mstover_ya
> ICQ: 152975688
> AIM: mstover777
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> 



Re: manipulating headers in pre-processor

Posted by ms...@apache.org.
Making a new HeaderManager and calling setHeaderManager 
ought to work.

-Mike

On 15 Sep 2003 at 12:19, Aaron Hamid wrote:

> Hi, I have written a pre-processor that modifies headers on an HTTPSampler (I need to do this because the header is dynamically derived), but the call getHeaderManager() on the HTTPSampler object always returns null.  Even if I have actually created a HeaderManager in the test configuration.  Creating a new HeaderManager object and programmatically calling setHeaderManager on the HTTPSampler object in my preprocessor doesn't do anything either.  Is there a way to dynamically modify outgoing request headers?
> 
> Aaron Hamid
> CIT/I&D
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-
unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-
help@jakarta.apache.org
> 




--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688
AIM: mstover777

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Re: manipulating headers in pre-processor

Posted by ms...@apache.org.
Making a new HeaderManager and calling setHeaderManager 
ought to work.

-Mike

On 15 Sep 2003 at 12:19, Aaron Hamid wrote:

> Hi, I have written a pre-processor that modifies headers on an HTTPSampler (I need to do this because the header is dynamically derived), but the call getHeaderManager() on the HTTPSampler object always returns null.  Even if I have actually created a HeaderManager in the test configuration.  Creating a new HeaderManager object and programmatically calling setHeaderManager on the HTTPSampler object in my preprocessor doesn't do anything either.  Is there a way to dynamically modify outgoing request headers?
> 
> Aaron Hamid
> CIT/I&D
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-
unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-
help@jakarta.apache.org
> 




--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688
AIM: mstover777