Allow the specification of a cookie name and property to fetch its value from for tracking URLs. Clientstep needs this so we can identify the user and correlate with their other events.

This commit is contained in:
Mike Thomas
2007-03-23 16:57:04 +00:00
parent 29b8e875de
commit 849c119227
2 changed files with 25 additions and 3 deletions
@@ -43,6 +43,7 @@ import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
@@ -351,6 +352,20 @@ public class Application
return getTrackingURL("pct" + percent);
}
/**
* Sets a cookie for a tracking URL if we have an appropriate property to fetch it from,
* an appropriate cookie name to assign, and the property is set to non-null.
*/
public void maybeSetTrackingCookie (URLConnection conn)
{
if (_trackingCookieName != null && _trackingCookieProperty != null) {
String val = System.getProperty(_trackingCookieProperty);
if (val != null) {
conn.setRequestProperty("Cookie", _trackingCookieName + "=" + val);
}
}
}
/**
* Instructs the application to parse its <code>getdown.txt</code> configuration and prepare
* itself for operation. The application base URL will be parsed first so that if there are
@@ -452,6 +467,10 @@ public class Application
_trackingPcts = new ArrayIntSet(new int[] { 50 });
}
// Check for tracking cookie configuration
_trackingCookieName = (String)cdata.get("tracking_cookie_name");
_trackingCookieProperty = (String)cdata.get("tracking_cookie_property");
// clear our arrays as we may be reinitializing
_codes.clear();
_resources.clear();
@@ -1089,6 +1108,8 @@ public class Application
protected String _trackingURL;
protected ArrayIntSet _trackingPcts;
protected String _trackingCookieName;
protected String _trackingCookieProperty;
protected int _javaVersion;
protected String _javaLocation;
@@ -691,7 +691,7 @@ public abstract class Getdown extends Thread
EventQueue.invokeLater(new Runnable() {
public void run () {
if (_status == null) {
_container = createContainer();
_container = createContainer();
_status = new StatusPanel(_msgs);
_container.add(_status, BorderLayout.CENTER);
}
@@ -784,7 +784,7 @@ public abstract class Getdown extends Thread
if (StringUtil.isBlank(path)) {
return null;
}
File imgpath = null;
try {
// First try for a localized image.
@@ -843,7 +843,7 @@ public abstract class Getdown extends Thread
protected abstract void exit (int exitCode);
/** Used to fetch a progress report URL. */
protected static class ProgressReporter extends Thread
protected class ProgressReporter extends Thread
{
public ProgressReporter (URL url) {
setDaemon(true);
@@ -853,6 +853,7 @@ public abstract class Getdown extends Thread
public void run () {
try {
HttpURLConnection ucon = (HttpURLConnection)_url.openConnection();
_app.maybeSetTrackingCookie(ucon);
ucon.connect();
try {
if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) {