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 Peter Molettiere <pi...@sfinteractive.com> on 2001/06/07 03:46:35 UTC

Suggested UrlConfig Patch


I've just been writing a new controller for a project
I'm working on, and found a need for a few enhancements
to org.apache.jmeter.protocol.http.config.UrlConfig.

1) UrlConfig didn't support any port other than 80. 
Often, people run webservers on non-standard ports,
such as 8080.

2) UrlConfig didn't support passing query strings to
GET urls, even if there was an Arguments object in the
UrlConfig's properties.

3) UrlConfig didn't support any protocol other than
http. (I'm thinking specifically about https, since
it looks like ftp, etc is handled by a separate package.

Here's a patch that provides both 1) and 2), and 
allows you to set arbitrary protocols on the UrlConfig,
even though setting non-http protocols (anything other
than http or https) will result in an Exception in
HTTPSampler. Further, https needs to be properly 
configured in the jvm to work correctly.

I've set it up so that if the port, protocol, or query
string isn't set, then the previous defaults are used.

In the case of port, I changed the default value to -1, 
since this is a flag to the java.net.URL constructor
which tells it to use the default port for the specified
protocol.


Peter
--
Peter Molettiere
senior engineer
sfinteractive.com


==========================================================


*** UrlConfig.java	Sat Mar 17 14:25:49 2001
--- UrlConfig.java	Wed Jun  6 18:06:28 2001
***************
*** 70,78 ****
--- 70,81 ----
  
  public class UrlConfig extends AbstractConfigElement
  {
+ 	public final static String PROTOCOL = "protocol";
  	public final static String DOMAIN = "domain";
  	public final static String PATH = "path";
  	public final static String METHOD = "method";
+ 	public final static String PORT = "port";
+ 	public final static String QUERYSTRING = "querystring";
  	public final static String ARGUMENTS = "arguments";
  	public final static String POST = "POST";
  	public final static String GET = "GET";
***************
*** 101,107 ****
  		{
  			setPath("/"+getPath());
  		}
! 		return new URL("http", (String)properties.get(DOMAIN), 80,
(String)properties.get(PATH));
  	}
  
  	public String getPath()
--- 104,110 ----
  		{
  			setPath("/"+getPath());
  		}
! 		return new URL(getProtocol(), (String)properties.get(DOMAIN),
getPort(), getPath() + getQueryString() );
  	}
  
  	public String getPath()
***************
*** 127,132 ****
--- 130,171 ----
  	public String getMethod()
  	{
  		return (String)properties.get(METHOD);
+ 	}
+ 
+ 	public void setPort( Integer p ) {
+ 	    properties.put(PORT,p);
+ 	}
+ 
+ 	public int getPort() {
+ 	    Integer p = (Integer) properties.get(PORT);
+ 	    if( p == null ) {
+ 		return -1;
+ 	    }
+ 	    return p.intValue();
+ 	}
+ 
+ 	public void setQueryString(String qs) {
+ 	    properties.put(QUERYSTRING, qs);
+ 	}
+ 
+ 	public String getQueryString() {
+ 	    String qs = (String) properties.get(QUERYSTRING);
+ 	    if( qs == null || qs.equals("") ) {
+ 		return "";
+ 	    }
+ 	    return "?" + qs;
+ 	}
+ 
+ 	public void setProtocol(String p) {
+ 	    properties.put(PROTOCOL, p);
+ 	}
+ 
+ 	public String getProtocol() {
+ 	    String p = (String) properties.get(PROTOCOL);
+ 	    if( p == null || p == "" ) {
+ 		return "http";
+ 	    }
+ 	    return p;
  	}
  
  	/************************************************************

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


Re: Suggested UrlConfig Patch

Posted by David Choy <da...@alloy.com>.
Wow, this is so cool..
Thanks

----- Original Message ----- 
From: "giacomo" <gi...@apache.org>
To: <jm...@jakarta.apache.org>
Sent: Thursday, June 07, 2001 1:10 AM
Subject: Re: Suggested UrlConfig Patch


> On Wed, 6 Jun 2001, Peter Molettiere wrote:
> 
> >
> >
> > I've just been writing a new controller for a project
> > I'm working on, and found a need for a few enhancements
> > to org.apache.jmeter.protocol.http.config.UrlConfig.
> >
> > 1) UrlConfig didn't support any port other than 80.
> > Often, people run webservers on non-standard ports,
> > such as 8080.
> 
> Which version have you looked at? We regularly test webservers running
> at different ports.
> 
> > 2) UrlConfig didn't support passing query strings to
> > GET urls, even if there was an Arguments object in the
> > UrlConfig's properties.
> 
> ??
> 
> > 3) UrlConfig didn't support any protocol other than
> > http. (I'm thinking specifically about https, since
> > it looks like ftp, etc is handled by a separate package.
> 
> https is well supported in the 1.6 dev version (dunno about 1.5)
> 
> Giacomo
> 
> > Here's a patch that provides both 1) and 2), and
> > allows you to set arbitrary protocols on the UrlConfig,
> > even though setting non-http protocols (anything other
> > than http or https) will result in an Exception in
> > HTTPSampler. Further, https needs to be properly
> > configured in the jvm to work correctly.
> >
> > I've set it up so that if the port, protocol, or query
> > string isn't set, then the previous defaults are used.
> >
> > In the case of port, I changed the default value to -1,
> > since this is a flag to the java.net.URL constructor
> > which tells it to use the default port for the specified
> > protocol.
> >
> >
> > Peter
> > --
> > Peter Molettiere
> > senior engineer
> > sfinteractive.com
> >
> >
> > ==========================================================
> >
> >
> > *** UrlConfig.java Sat Mar 17 14:25:49 2001
> > --- UrlConfig.java Wed Jun  6 18:06:28 2001
> > ***************
> > *** 70,78 ****
> > --- 70,81 ----
> >
> >   public class UrlConfig extends AbstractConfigElement
> >   {
> > + public final static String PROTOCOL = "protocol";
> >   public final static String DOMAIN = "domain";
> >   public final static String PATH = "path";
> >   public final static String METHOD = "method";
> > + public final static String PORT = "port";
> > + public final static String QUERYSTRING = "querystring";
> >   public final static String ARGUMENTS = "arguments";
> >   public final static String POST = "POST";
> >   public final static String GET = "GET";
> > ***************
> > *** 101,107 ****
> >   {
> >   setPath("/"+getPath());
> >   }
> > ! return new URL("http", (String)properties.get(DOMAIN), 80,
> > (String)properties.get(PATH));
> >   }
> >
> >   public String getPath()
> > --- 104,110 ----
> >   {
> >   setPath("/"+getPath());
> >   }
> > ! return new URL(getProtocol(), (String)properties.get(DOMAIN),
> > getPort(), getPath() + getQueryString() );
> >   }
> >
> >   public String getPath()
> > ***************
> > *** 127,132 ****
> > --- 130,171 ----
> >   public String getMethod()
> >   {
> >   return (String)properties.get(METHOD);
> > + }
> > +
> > + public void setPort( Integer p ) {
> > +     properties.put(PORT,p);
> > + }
> > +
> > + public int getPort() {
> > +     Integer p = (Integer) properties.get(PORT);
> > +     if( p == null ) {
> > + return -1;
> > +     }
> > +     return p.intValue();
> > + }
> > +
> > + public void setQueryString(String qs) {
> > +     properties.put(QUERYSTRING, qs);
> > + }
> > +
> > + public String getQueryString() {
> > +     String qs = (String) properties.get(QUERYSTRING);
> > +     if( qs == null || qs.equals("") ) {
> > + return "";
> > +     }
> > +     return "?" + qs;
> > + }
> > +
> > + public void setProtocol(String p) {
> > +     properties.put(PROTOCOL, p);
> > + }
> > +
> > + public String getProtocol() {
> > +     String p = (String) properties.get(PROTOCOL);
> > +     if( p == null || p == "" ) {
> > + return "http";
> > +     }
> > +     return p;
> >   }
> >
> >   /************************************************************
> >
> > ---------------------------------------------------------------------
> > 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
> 


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


Re: Suggested UrlConfig Patch

Posted by giacomo <gi...@apache.org>.
On Thu, 7 Jun 2001, Peter Molettiere wrote:

>
> giacomo wrote:
>
> > > 1) UrlConfig didn't support any port other than 80.
> > > Often, people run webservers on non-standard ports,
> > > such as 8080.
> >
> > Which version have you looked at? We regularly test webservers running
> > at different ports.
>
>
> 1.6Alpha -- the latest release. Which version are you using?
> A nightly build? The cvs source? I guess the 1.6 alpha release
> is a couple months old.

Nighly builds.

> Are you using the default web testing controller and url
> sample configuration elements included in the jar, or have
> you rolled your own?

No custom stuff. I use it out-of-the-box

> > > 2) UrlConfig didn't support passing query strings to
> > > GET urls, even if there was an Arguments object in the
> > > UrlConfig's properties.
> >
> > ??
>
>
> What's unclear?
>
>
> > > 3) UrlConfig didn't support any protocol other than
> > > http. (I'm thinking specifically about https, since
> > > it looks like ftp, etc is handled by a separate package.
> >
> > https is well supported in the 1.6 dev version (dunno about 1.5)
>
>
> Hard to see how this supports https, arbitrary ports, or query strings:
>
> org.apache.jmeter.protocol.http.config.UrlConfig line 104:
>
> return new URL( "http", (String)properties.get(DOMAIN), 80,
>                 (String)properties.get(PATH) );

You must definitively have another version than I have. I use nightly
build and I think in there is a description how to get it working with
the https protocol. The web testing controloer as well as the url sample
offers a Port field to enter. I regularly test servlet served by Tomcat
at port 8080 and 8443 (https) and I don't have any problems. I do tests
for custom login pages with parameters and POST methods.

Giacomo

>
>
> Maybe I'm not understanding something somewhere... maybe you
> can point me in the right direction?
>
>
> peter
>
> ---------------------------------------------------------------------
> 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: Suggested UrlConfig Patch

Posted by Peter Molettiere <pi...@santoshima.org>.
giacomo wrote:

> > 1) UrlConfig didn't support any port other than 80.
> > Often, people run webservers on non-standard ports,
> > such as 8080.
> 
> Which version have you looked at? We regularly test webservers running
> at different ports.


1.6Alpha -- the latest release. Which version are you using? 
A nightly build? The cvs source? I guess the 1.6 alpha release
is a couple months old.

Are you using the default web testing controller and url 
sample configuration elements included in the jar, or have
you rolled your own?

 
> > 2) UrlConfig didn't support passing query strings to
> > GET urls, even if there was an Arguments object in the
> > UrlConfig's properties.
> 
> ??


What's unclear?

 
> > 3) UrlConfig didn't support any protocol other than
> > http. (I'm thinking specifically about https, since
> > it looks like ftp, etc is handled by a separate package.
> 
> https is well supported in the 1.6 dev version (dunno about 1.5)


Hard to see how this supports https, arbitrary ports, or query strings:

org.apache.jmeter.protocol.http.config.UrlConfig line 104:

return new URL( "http", (String)properties.get(DOMAIN), 80, 
                (String)properties.get(PATH) );


Maybe I'm not understanding something somewhere... maybe you
can point me in the right direction?


peter

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


Re: Suggested UrlConfig Patch

Posted by giacomo <gi...@apache.org>.
On Wed, 6 Jun 2001, Peter Molettiere wrote:

>
>
> I've just been writing a new controller for a project
> I'm working on, and found a need for a few enhancements
> to org.apache.jmeter.protocol.http.config.UrlConfig.
>
> 1) UrlConfig didn't support any port other than 80.
> Often, people run webservers on non-standard ports,
> such as 8080.

Which version have you looked at? We regularly test webservers running
at different ports.

> 2) UrlConfig didn't support passing query strings to
> GET urls, even if there was an Arguments object in the
> UrlConfig's properties.

??

> 3) UrlConfig didn't support any protocol other than
> http. (I'm thinking specifically about https, since
> it looks like ftp, etc is handled by a separate package.

https is well supported in the 1.6 dev version (dunno about 1.5)

Giacomo

> Here's a patch that provides both 1) and 2), and
> allows you to set arbitrary protocols on the UrlConfig,
> even though setting non-http protocols (anything other
> than http or https) will result in an Exception in
> HTTPSampler. Further, https needs to be properly
> configured in the jvm to work correctly.
>
> I've set it up so that if the port, protocol, or query
> string isn't set, then the previous defaults are used.
>
> In the case of port, I changed the default value to -1,
> since this is a flag to the java.net.URL constructor
> which tells it to use the default port for the specified
> protocol.
>
>
> Peter
> --
> Peter Molettiere
> senior engineer
> sfinteractive.com
>
>
> ==========================================================
>
>
> *** UrlConfig.java	Sat Mar 17 14:25:49 2001
> --- UrlConfig.java	Wed Jun  6 18:06:28 2001
> ***************
> *** 70,78 ****
> --- 70,81 ----
>
>   public class UrlConfig extends AbstractConfigElement
>   {
> + 	public final static String PROTOCOL = "protocol";
>   	public final static String DOMAIN = "domain";
>   	public final static String PATH = "path";
>   	public final static String METHOD = "method";
> + 	public final static String PORT = "port";
> + 	public final static String QUERYSTRING = "querystring";
>   	public final static String ARGUMENTS = "arguments";
>   	public final static String POST = "POST";
>   	public final static String GET = "GET";
> ***************
> *** 101,107 ****
>   		{
>   			setPath("/"+getPath());
>   		}
> ! 		return new URL("http", (String)properties.get(DOMAIN), 80,
> (String)properties.get(PATH));
>   	}
>
>   	public String getPath()
> --- 104,110 ----
>   		{
>   			setPath("/"+getPath());
>   		}
> ! 		return new URL(getProtocol(), (String)properties.get(DOMAIN),
> getPort(), getPath() + getQueryString() );
>   	}
>
>   	public String getPath()
> ***************
> *** 127,132 ****
> --- 130,171 ----
>   	public String getMethod()
>   	{
>   		return (String)properties.get(METHOD);
> + 	}
> +
> + 	public void setPort( Integer p ) {
> + 	    properties.put(PORT,p);
> + 	}
> +
> + 	public int getPort() {
> + 	    Integer p = (Integer) properties.get(PORT);
> + 	    if( p == null ) {
> + 		return -1;
> + 	    }
> + 	    return p.intValue();
> + 	}
> +
> + 	public void setQueryString(String qs) {
> + 	    properties.put(QUERYSTRING, qs);
> + 	}
> +
> + 	public String getQueryString() {
> + 	    String qs = (String) properties.get(QUERYSTRING);
> + 	    if( qs == null || qs.equals("") ) {
> + 		return "";
> + 	    }
> + 	    return "?" + qs;
> + 	}
> +
> + 	public void setProtocol(String p) {
> + 	    properties.put(PROTOCOL, p);
> + 	}
> +
> + 	public String getProtocol() {
> + 	    String p = (String) properties.get(PROTOCOL);
> + 	    if( p == null || p == "" ) {
> + 		return "http";
> + 	    }
> + 	    return p;
>   	}
>
>   	/************************************************************
>
> ---------------------------------------------------------------------
> 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