net.grinder.plugin.http
Interface HTTPUtilities


public interface HTTPUtilities

Things that HTTP scripts find useful.

Author:
Philip Aston
See Also:
HTTPPluginControl.getHTTPUtilities()

Method Summary
 NVPair basicAuthorizationHeader(java.lang.String userID, java.lang.String password)
          Create a NVPair for an HTTP Basic Authorization header.
 HTTPResponse getLastResponse()
          Return the response for the last request made by the calling worker thread.
 java.lang.String valueFromBodyInput(java.lang.String tokenName)
          Return the value for an input token with the given tokenName in the body of the last response.
 java.lang.String valueFromBodyInput(java.lang.String tokenName, java.lang.String afterText)
          Return the value for an input token with the given tokenName in the body of the last response.
 java.lang.String valueFromBodyURI(java.lang.String tokenName)
          Return the value for a path parameter or query string name-value token with the given tokenName in a URI in the body of the last response.
 java.lang.String valueFromBodyURI(java.lang.String tokenName, java.lang.String afterText)
          Return the value for a path parameter or query string name-value token with the given tokenName in a URI in the body of the last response.
 java.lang.String valueFromHiddenInput(java.lang.String tokenName)
          Return the value for a hidden input token with the given tokenName in the body of the last response.
 java.lang.String valueFromHiddenInput(java.lang.String tokenName, java.lang.String afterText)
          Return the value for a hidden input token with the given tokenName in the body of the last response.
 java.lang.String valueFromLocationURI(java.lang.String tokenName)
          Return the value for a path parameter or query string name-value token with the given tokenName in a Location header from the last response.
 java.util.List<java.lang.String> valuesFromBodyInput(java.lang.String tokenName)
          Return all matching values for input tokens with the given tokenName in the body of the last response.
 java.util.List<java.lang.String> valuesFromBodyInput(java.lang.String tokenName, java.lang.String afterText)
          Return all matching values for input tokens with the given tokenName in the body of the last response.
 java.util.List<java.lang.String> valuesFromBodyURI(java.lang.String tokenName)
          Return all matching values for path parameters or query string name-value tokens with the given tokenName in a URI in the body of the last response.
 java.util.List<java.lang.String> valuesFromBodyURI(java.lang.String tokenName, java.lang.String afterText)
          Return all matching values for path parameters or query string name-value tokens with the given tokenName in a URI in the body of the last response.
 java.util.List<java.lang.String> valuesFromHiddenInput(java.lang.String tokenName)
          Return all matching values for hidden input tokens with the given tokenName in the body of the last response.
 java.util.List<java.lang.String> valuesFromHiddenInput(java.lang.String tokenName, java.lang.String afterText)
          Return all matching values for hidden input tokens with the given tokenName in the body of the last response.
 

Method Detail

basicAuthorizationHeader

NVPair basicAuthorizationHeader(java.lang.String userID,
                                java.lang.String password)
Create a NVPair for an HTTP Basic Authorization header.

Parameters:
userID - The user name.
password - The password.
Returns:
The NVPair that can be used as a header with HTTPRequest.

getLastResponse

HTTPResponse getLastResponse()
                             throws GrinderException
Return the response for the last request made by the calling worker thread.

Returns:
The response, or null if the calling thread has not made any requests.
Throws:
GrinderException - If not called from a worker thread.

valueFromLocationURI

java.lang.String valueFromLocationURI(java.lang.String tokenName)
                                      throws GrinderException
Return the value for a path parameter or query string name-value token with the given tokenName in a Location header from the last response. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
Returns:
The first value if one is found.
Throws:
GrinderException - If not called from a worker thread.

valueFromBodyInput

java.lang.String valueFromBodyInput(java.lang.String tokenName)
                                    throws GrinderException
Return the value for an input token with the given tokenName in the body of the last response. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
Returns:
The first value if one is found, or an empty string.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyInput(String, String), valuesFromBodyInput(String)

valueFromBodyInput

java.lang.String valueFromBodyInput(java.lang.String tokenName,
                                    java.lang.String afterText)
                                    throws GrinderException
Return the value for an input token with the given tokenName in the body of the last response. If there are multiple matches, the first value is returned. This version of valueFromBodyInput only considers matches following the first occurrence of the literal text afterText. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The first value if one is found, or an empty string if the body does not contain afterText followed by a URI containing a token with name tokenName.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyInput(String), valuesFromBodyInput(String, String)

valuesFromBodyInput

java.util.List<java.lang.String> valuesFromBodyInput(java.lang.String tokenName)
                                                     throws GrinderException
Return all matching values for input tokens with the given tokenName in the body of the last response.

Parameters:
tokenName - The token name.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyInput(String), valuesFromBodyInput(String, String)

valuesFromBodyInput

java.util.List<java.lang.String> valuesFromBodyInput(java.lang.String tokenName,
                                                     java.lang.String afterText)
                                                     throws GrinderException
Return all matching values for input tokens with the given tokenName in the body of the last response. This version of valueFromBodyInput only considers matches following the first occurrence of the literal text afterText.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valuesFromBodyInput(String), valueFromBodyInput(String, String)

valueFromHiddenInput

java.lang.String valueFromHiddenInput(java.lang.String tokenName)
                                      throws GrinderException
Return the value for a hidden input token with the given tokenName in the body of the last response. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
Returns:
The first value if one is found, or an empty string.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromHiddenInput(String, String), valuesFromHiddenInput(String)

valueFromHiddenInput

java.lang.String valueFromHiddenInput(java.lang.String tokenName,
                                      java.lang.String afterText)
                                      throws GrinderException
Return the value for a hidden input token with the given tokenName in the body of the last response. If there are multiple matches, the first value is returned. This version of valueFromHiddenInput only considers matches following the first occurrence of the literal text afterText. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The first value if one is found, or an empty string if the body does not contain afterText followed by a URI containing a token with name tokenName.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromHiddenInput(String), valuesFromHiddenInput(String, String)

valuesFromHiddenInput

java.util.List<java.lang.String> valuesFromHiddenInput(java.lang.String tokenName)
                                                       throws GrinderException
Return all matching values for hidden input tokens with the given tokenName in the body of the last response.

Parameters:
tokenName - The token name.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromHiddenInput(String), valuesFromHiddenInput(String, String)

valuesFromHiddenInput

java.util.List<java.lang.String> valuesFromHiddenInput(java.lang.String tokenName,
                                                       java.lang.String afterText)
                                                       throws GrinderException
Return all matching values for hidden input tokens with the given tokenName in the body of the last response. This version of valueFromHiddenInput only considers matches following the first occurrence of the literal text afterText.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valuesFromHiddenInput(String), valueFromHiddenInput(String, String)

valueFromBodyURI

java.lang.String valueFromBodyURI(java.lang.String tokenName)
                                  throws GrinderException
Return the value for a path parameter or query string name-value token with the given tokenName in a URI in the body of the last response. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
Returns:
The first value if one is found, or an empty string.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyURI(String, String), valuesFromBodyURI(String)

valueFromBodyURI

java.lang.String valueFromBodyURI(java.lang.String tokenName,
                                  java.lang.String afterText)
                                  throws GrinderException
Return the value for a path parameter or query string name-value token with the given tokenName in a URI in the body of the last response. This version of valueFromBodyURI only considers matches following the first occurrence of the literal text afterText. If there are multiple matches, the first value is returned.

If there is no match, an empty string is returned rather than null. This makes scripts more robust (as they don't need to check the value before using it), but they lose the ability to distinguish between a missing token and an empty value.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The first value if one is found, or an empty string if the body does not contain afterText followed by a URI containing a token with name tokenName.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyURI(String), valuesFromBodyURI(String, String)

valuesFromBodyURI

java.util.List<java.lang.String> valuesFromBodyURI(java.lang.String tokenName)
                                                   throws GrinderException
Return all matching values for path parameters or query string name-value tokens with the given tokenName in a URI in the body of the last response.

Parameters:
tokenName - The token name.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valueFromBodyURI(String), valuesFromBodyURI(String, String)

valuesFromBodyURI

java.util.List<java.lang.String> valuesFromBodyURI(java.lang.String tokenName,
                                                   java.lang.String afterText)
                                                   throws GrinderException
Return all matching values for path parameters or query string name-value tokens with the given tokenName in a URI in the body of the last response. This version of valueFromBodyURI only considers matches following the first occurrence of the literal text afterText.

Parameters:
tokenName - The token name.
afterText - The search begins after the first occurrence of this literal text.
Returns:
The matching values.
Throws:
GrinderException - If not called from a worker thread.
See Also:
valuesFromBodyURI(String), valueFromBodyURI(String, String)