A sampler which understands all the parts necessary to read statistics about
HTTP requests, including cookies and authentication.
disconnect
protected void disconnect(HttpURLConnection conn)
getResponseHeaders
protected String getResponseHeaders(HttpURLConnection conn)
Gets the ResponseHeaders from the URLConnection
conn
- connection from which the headers are read
- string containing the headers, one per line
readResponse
protected byte[] readResponse(HttpURLConnection conn,
SampleResult res)
throws IOException
Reads the response from the URL connection.
conn
- URL from which to read response
sample
protected HTTPSampleResult sample(URL url,
String method,
boolean areFollowingRedirect,
int frameDepth)
Samples the URL passed in and stores the result in
HTTPSampleResult
, following redirects and downloading
page resources as appropriate.
When getting a redirect target, redirects are not followed and resources
are not downloaded. The caller will take care of this.
- sample in interface HTTPSamplerBase
url
- URL to samplemethod
- HTTP method: GET, POST,...areFollowingRedirect
- whether we're getting a redirect targetframeDepth
- Depth of this target in the frame structure. Used only to
prevent infinite recursion.
sendPostData
protected String sendPostData(URLConnection connection)
throws IOException
Send POST data from Entry
to the open connection.
This also handles sending data for PUT requests
connection
- URLConnection
where POST data should be sent
- a String show what was posted. Will not contain actual file upload content
setPostHeaders
protected void setPostHeaders(URLConnection conn)
throws IOException
Set request headers in preparation to opening a connection.
conn
- URLConnection
to set headers on
setupConnection
protected HttpURLConnection setupConnection(URL u,
String method,
HTTPSampleResult res)
throws IOException
Returns an
HttpURLConnection
fully ready to attempt
connection. This means it sets the request method (GET or POST), headers,
cookies, and authorization for the URL request.
The request infos are saved into the sample result if one is provided.
u
- URL
of the URL requestmethod
- GET, POST etcres
- sample result to save request infos to
HttpURLConnection
ready for .connect