Apache JMeter
1.9

org.apache.jmeter.protocol.http.sampler
Class HTTPSamplerFull

java.lang.Object
  |
  +--org.apache.jmeter.protocol.http.sampler.HTTPSamplerFull

public class HTTPSamplerFull
extends Object

A sampler that downloads downloadable components such as images, applets, etc.

For HTML files, this class will download binary files specified in the following ways (where url represents the binary file to be downloaded):

Note that files that are duplicated within the enclosing document will only be downloaded once. Also, the processing does not take account of the following parameters: The following parameters are not accounted for either (as the textbooks say, they are left as an exercise for the interested reader): Due to the recent refactoring of this class, these might not be as difficult as they once might have been.

Finally, this class does not process Style Sheets either.

Version:
$Id: HTTPSamplerFull.java,v 1.13 2003/06/23 20:28:02 thads Exp $
Author:
Khor Soon Hin, Martin Ramshaw

Nested Class Summary
static class HTTPSamplerFull.Test
           
 
Field Summary
protected  URL baseUrl
          Used to store the base URL.
protected static String utfEncodingName
          Used to store the UTF encoding name (which is version dependent).
 
Constructor Summary
HTTPSamplerFull()
          This is the only Constructor.
 
Method Summary
protected static org.w3c.dom.Node getDOM(String text)
          Returns a node representing a whole xml given an xml document.
protected  int getErrorLevel(HttpURLConnection conn, SampleResult res)
          Get the response code of the URL connection and divide it by 100 thus returning 2 (for 2xx response codes), 3 (for 3xx reponse codes), etc.
protected static org.w3c.tidy.Tidy getParser()
          Returns tidy as HTML parser.
protected static String getUTFEncodingName()
          Returns the encoding type which is different for different jdks even though they mean the same thing (for example, UTF8 or UTF-8).
protected  byte[] loadBinary(URL url, SampleResult res, HTTPSampler sampler)
          Download the binary file from the given URL.
protected  SampleResult parseForImages(SampleResult res, HTTPSampler sampler)
           
protected  void parseNodes(org.w3c.dom.Document html, String htmlTag, boolean type, String srcTag, Set uniques, SampleResult res, HTTPSampler sampler)
          Parse the DOM tree looking for the specified HTML source tags, and download the appropriate binary files matching these tags.
 SampleResult sample(HTTPSampler sampler)
          Samples the Entry passed in and stores the result in SampleResult.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

utfEncodingName

protected static String utfEncodingName
Used to store the UTF encoding name (which is version dependent).

See Also:
getUTFEncodingName()

baseUrl

protected URL baseUrl
Used to store the base URL. It should probably be updated to respect the following parameter:
     <base href=url>
 

Constructor Detail

HTTPSamplerFull

public HTTPSamplerFull()
This is the only Constructor.

Method Detail

sample

public SampleResult sample(HTTPSampler sampler)
Samples the Entry passed in and stores the result in SampleResult. The original file (which is assumed to be an HTML file) is parsed into a DOM tree and examined for embedded binary files.

Note that files that are duplicated within the enclosing document will only be downloaded once.

Returns:
results of the sampling

parseForImages

protected SampleResult parseForImages(SampleResult res,
                                      HTTPSampler sampler)

parseNodes

protected void parseNodes(org.w3c.dom.Document html,
                          String htmlTag,
                          boolean type,
                          String srcTag,
                          Set uniques,
                          SampleResult res,
                          HTTPSampler sampler)
Parse the DOM tree looking for the specified HTML source tags, and download the appropriate binary files matching these tags.

Parameters:
html - the HTML document to parse
htmlTag - the HTML tag to parse for
type - indicates that we require 'type=image'
srcTag - the HTML tag that indicates the source URL
uniques - used to ensure that binary files are only downloaded once
res - SampleResult to store sampling results

loadBinary

protected byte[] loadBinary(URL url,
                            SampleResult res,
                            HTTPSampler sampler)
                     throws Exception
Download the binary file from the given URL.

Parameters:
url - URL from where binary is to be downloaded
res - SampleResult to store sampling results
Returns:
binary downloaded
Throws:
IOException - indicates a problem reading from the URL
Exception

getErrorLevel

protected int getErrorLevel(HttpURLConnection conn,
                            SampleResult res)
Get the response code of the URL connection and divide it by 100 thus returning 2 (for 2xx response codes), 3 (for 3xx reponse codes), etc.

Parameters:
conn - HttpURLConnection of URL request
res - where all results of sampling will be stored
Returns:
HTTP response code divided by 100

getParser

protected static org.w3c.tidy.Tidy getParser()
Returns tidy as HTML parser.

Returns:
a tidy HTML parser

getDOM

protected static org.w3c.dom.Node getDOM(String text)
                                  throws org.xml.sax.SAXException
Returns a node representing a whole xml given an xml document.

Parameters:
text - an xml document
Returns:
a node representing a whole xml
Throws:
org.xml.sax.SAXException - indicates an error parsing the xml document

getUTFEncodingName

protected static String getUTFEncodingName()
Returns the encoding type which is different for different jdks even though they mean the same thing (for example, UTF8 or UTF-8).

Returns:
either UTF8 or UTF-8 depending on the jdk version
See Also:
utfEncodingName

Apache JMeter
1.9

Copyright © 1998-2003 Apache Software Foundation. All Rights Reserved.