View | Details | Raw Unified | Return to bug 41876
Collapse All | Expand All

(-)C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java (-6 / +20 lines)
Lines 98-112 Link Here
98
	 * Main processing method for the Proxy object
98
	 * Main processing method for the Proxy object
99
	 */
99
	 */
100
	public void run() {
100
	public void run() {
101
		HttpRequestHdr request = new HttpRequestHdr();
101
		// Check which HTTPSampler class we should use
102
		String httpSamplerName = HTTPSamplerFactory.DEFAULT_CLASSNAME;
103
		if(target.getSamplerTypeName() == ProxyControl.SAMPLER_TYPE_HTTP_SAMPLER) {
104
			httpSamplerName = HTTPSamplerFactory.HTTP_SAMPLER_JAVA;
105
		}
106
		else if(target.getSamplerTypeName() == ProxyControl.SAMPLER_TYPE_HTTP_SAMPLER2) {
107
			httpSamplerName = HTTPSamplerFactory.HTTP_SAMPLER_APACHE;
108
		}
109
		// Instantiate the sampler
110
		HTTPSamplerBase sampler = HTTPSamplerFactory.newInstance(httpSamplerName);
111
		sampler.threadStarted();
112
		
113
		HttpRequestHdr request = new HttpRequestHdr(sampler);
102
		SampleResult result = null;
114
		SampleResult result = null;
103
		HeaderManager headers = null;
115
		HeaderManager headers = null;
104
116
105
		HTTPSamplerBase sampler = null;
106
		try {
117
		try {
107
			request.parse(new BufferedInputStream(clientSocket.getInputStream()));
118
			request.parse(new BufferedInputStream(clientSocket.getInputStream()));
108
119
109
			sampler = request.getSampler();
120
			// Populate the sampler. It is the same sampler as we sent into
121
			// the constructor of the HttpRequestHdr instance above 
122
			request.getSampler();
110
123
111
			/*
124
			/*
112
			 * Create a Header Manager to ensure that the browsers headers are
125
			 * Create a Header Manager to ensure that the browsers headers are
Lines 145-154 Link Here
145
			log.error("", e);
158
			log.error("", e);
146
			writeErrorToClient(HttpReplyHdr.formTimeout());
159
			writeErrorToClient(HttpReplyHdr.formTimeout());
147
		} finally {
160
		} finally {
148
            if (sampler == null){
161
			if (log.isDebugEnabled()) {
149
                sampler = HTTPSamplerFactory.newInstance();
162
				log.debug("Will deliver sample " + sampler.getName());
150
            }
163
			}
151
			target.deliverSampler(sampler, new TestElement[] { captureHttpHeaders ? headers : null }, result);
164
			target.deliverSampler(sampler, new TestElement[] { captureHttpHeaders ? headers : null }, result);
165
			sampler.threadFinished();
152
			try {
166
			try {
153
				clientSocket.close();
167
				clientSocket.close();
154
			} catch (Exception e) {
168
			} catch (Exception e) {
(-)C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java (-4 / +60 lines)
Lines 41-46 Link Here
41
import org.apache.jmeter.protocol.http.control.HeaderManager;
41
import org.apache.jmeter.protocol.http.control.HeaderManager;
42
import org.apache.jmeter.protocol.http.control.RecordingController;
42
import org.apache.jmeter.protocol.http.control.RecordingController;
43
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
43
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
44
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui2;
44
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
45
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
45
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
46
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
46
import org.apache.jmeter.samplers.SampleEvent;
47
import org.apache.jmeter.samplers.SampleEvent;
Lines 76-84 Link Here
76
    /*
77
    /*
77
     * Use class names so the complier can detect if a class is renamed/deleted
78
     * Use class names so the complier can detect if a class is renamed/deleted
78
     */
79
     */
79
    //  TODO - allow for HttpClient sampler ...
80
	private static final String HTTP_TEST_SAMPLE_GUI = HttpTestSampleGui.class.getName();
81
82
    private static final String ASSERTION_GUI = AssertionGui.class.getName();
80
    private static final String ASSERTION_GUI = AssertionGui.class.getName();
83
81
84
    private static final String LOGIC_CONTROLLER_GUI = LogicControllerGui.class.getName(); 
82
    private static final String LOGIC_CONTROLLER_GUI = LogicControllerGui.class.getName(); 
Lines 105-112 Link Here
105
103
106
	public static final String GROUPING_MODE = "ProxyControlGui.grouping_mode"; // $NON-NLS-1$
104
	public static final String GROUPING_MODE = "ProxyControlGui.grouping_mode"; // $NON-NLS-1$
107
105
106
	public static final String SAMPLER_TYPE_NAME = "ProxyControlGui.sampler_type_name"; // $NON-NLS-1$
107
108
	public static final String SAMPLER_REDIRECT_AUTOMATICALLY = "ProxyControlGui.sampler_redirect_automatically"; // $NON-NLS-1$
109
110
	public static final String SAMPLER_FOLLOW_REDIRECTS = "ProxyControlGui.sampler_follow_redirects"; // $NON-NLS-1$
111
108
	public static final String USE_KEEPALIVE = "ProxyControlGui.use_keepalive"; // $NON-NLS-1$
112
	public static final String USE_KEEPALIVE = "ProxyControlGui.use_keepalive"; // $NON-NLS-1$
109
113
114
	public static final String SAMPLER_DOWNLOAD_IMAGES = "ProxyControlGui.sampler_download_images"; // $NON-NLS-1$
115
110
	public static final String REGEX_MATCH = "ProxyControlGui.regex_match"; // $NON-NLS-1$
116
	public static final String REGEX_MATCH = "ProxyControlGui.regex_match"; // $NON-NLS-1$
111
117
112
	public static final String HTTPS_SPOOF = "ProxyControlGui.https_spoof";
118
	public static final String HTTPS_SPOOF = "ProxyControlGui.https_spoof";
Lines 118-124 Link Here
118
	public static final int GROUPING_IN_CONTROLLERS = 2;
124
	public static final int GROUPING_IN_CONTROLLERS = 2;
119
125
120
	public static final int GROUPING_STORE_FIRST_ONLY = 3;
126
	public static final int GROUPING_STORE_FIRST_ONLY = 3;
127
	
128
	public static final int SAMPLER_TYPE_HTTP_SAMPLER = 0;
121
129
130
	public static final int SAMPLER_TYPE_HTTP_SAMPLER2 = 1;
131
122
	private long lastTime = 0;// When was the last sample seen?
132
	private long lastTime = 0;// When was the last sample seen?
123
133
124
	private static final long sampleGap =
134
	private static final long sampleGap =
Lines 128-136 Link Here
128
	private boolean addAssertions;
138
	private boolean addAssertions;
129
139
130
	private int groupingMode;
140
	private int groupingMode;
141
	
142
	private int samplerTypeName;
131
143
144
	private boolean samplerRedirectAutomatically;
145
146
	private boolean samplerFollowRedirects;
147
	
132
	private boolean useKeepAlive;
148
	private boolean useKeepAlive;
133
149
150
	private boolean samplerDownloadImages;
151
134
	private boolean regexMatch = false;// Should we match using regexes?
152
	private boolean regexMatch = false;// Should we match using regexes?
135
	
153
	
136
	/**
154
	/**
Lines 169-174 Link Here
169
		setProperty(new BooleanProperty(ADD_ASSERTIONS, b));
187
		setProperty(new BooleanProperty(ADD_ASSERTIONS, b));
170
	}
188
	}
171
189
190
	public void setSamplerTypeName(int samplerTypeName) {
191
		this.samplerTypeName = samplerTypeName;
192
		setProperty(new IntegerProperty(SAMPLER_TYPE_NAME, samplerTypeName));
193
	}
194
195
	public void setSamplerRedirectAutomatically(boolean b) {
196
		samplerRedirectAutomatically = b;
197
		setProperty(new BooleanProperty(SAMPLER_REDIRECT_AUTOMATICALLY, b));
198
	}
199
200
	public void setSamplerFollowRedirects(boolean b) {
201
		samplerFollowRedirects = b;
202
		setProperty(new BooleanProperty(SAMPLER_FOLLOW_REDIRECTS, b));
203
	}
204
172
	/**
205
	/**
173
	 * @param b
206
	 * @param b
174
	 */
207
	 */
Lines 177-182 Link Here
177
		setProperty(new BooleanProperty(USE_KEEPALIVE, b));
210
		setProperty(new BooleanProperty(USE_KEEPALIVE, b));
178
	}
211
	}
179
212
213
	public void setSamplerDownloadImages(boolean b) {
214
		samplerDownloadImages = b;
215
		setProperty(new BooleanProperty(SAMPLER_DOWNLOAD_IMAGES, b));
216
	}
217
180
	public void setIncludeList(Collection list) {
218
	public void setIncludeList(Collection list) {
181
		setProperty(new CollectionProperty(INCLUDE_LIST, new HashSet(list)));
219
		setProperty(new CollectionProperty(INCLUDE_LIST, new HashSet(list)));
182
	}
220
	}
Lines 228-236 Link Here
228
		return getPropertyAsBoolean(CAPTURE_HTTP_HEADERS);
266
		return getPropertyAsBoolean(CAPTURE_HTTP_HEADERS);
229
	}
267
	}
230
268
269
	public int getSamplerTypeName() {
270
		return getPropertyAsInt(SAMPLER_TYPE_NAME);
271
	}
272
	
273
	public boolean getSamplerRedirectAutomatically() {
274
		return getPropertyAsBoolean(SAMPLER_REDIRECT_AUTOMATICALLY, false);
275
	}
276
277
	public boolean getSamplerFollowRedirects() {
278
		return getPropertyAsBoolean(SAMPLER_FOLLOW_REDIRECTS, true);
279
	}
280
	
231
	public boolean getUseKeepalive() {
281
	public boolean getUseKeepalive() {
232
		return getPropertyAsBoolean(USE_KEEPALIVE, true);
282
		return getPropertyAsBoolean(USE_KEEPALIVE, true);
233
	}
283
	}
284
	
285
	public boolean getSamplerDownloadImages() {
286
		return getPropertyAsBoolean(SAMPLER_DOWNLOAD_IMAGES, false);
287
	}
234
288
235
	public boolean getRegexMatch() {
289
	public boolean getRegexMatch() {
236
		return getPropertyAsBoolean(REGEX_MATCH, false);
290
		return getPropertyAsBoolean(REGEX_MATCH, false);
Lines 307-314 Link Here
307
361
308
			removeValuesFromSampler(sampler, defaultConfigurations);
362
			removeValuesFromSampler(sampler, defaultConfigurations);
309
			replaceValues(sampler, subConfigs, userDefinedVariables);
363
			replaceValues(sampler, subConfigs, userDefinedVariables);
364
			sampler.setAutoRedirects(samplerRedirectAutomatically);
365
			sampler.setFollowRedirects(samplerFollowRedirects);
310
			sampler.setUseKeepAlive(useKeepAlive);
366
			sampler.setUseKeepAlive(useKeepAlive);
311
			sampler.setProperty(TestElement.GUI_CLASS, HTTP_TEST_SAMPLE_GUI);
367
			sampler.setImageParser(samplerDownloadImages);
312
368
313
			placeSampler(sampler, subConfigs, myTarget);
369
			placeSampler(sampler, subConfigs, myTarget);
314
370
(-)C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java (-24 / +112 lines)
Lines 93-107 Link Here
93
	 */
93
	 */
94
	private JCheckBox addAssertions;
94
	private JCheckBox addAssertions;
95
95
96
	/*
97
	 * Use regexes to match the source data
98
	 */
99
	private JCheckBox regexMatch;
100
96
	/**
101
	/**
102
	 * The list of sampler type names to choose from
103
	 */
104
	private JComboBox samplerTypeName;
105
106
	private DefaultComboBoxModel samplerTypeNameModel;
107
	
108
	/**
109
	 * Set/clear the Redirect automatically box on the samplers (default is false)
110
	 */
111
	private JCheckBox samplerRedirectAutomatically;
112
	/**
113
	 * Set/clear the Follow-redirects box on the samplers (default is true)
114
	 */
115
	private JCheckBox samplerFollowRedirects;
116
117
	/**
97
	 * Set/clear the Use Keep-Alive box on the samplers (default is true)
118
	 * Set/clear the Use Keep-Alive box on the samplers (default is true)
98
	 */
119
	 */
99
	private JCheckBox useKeepAlive;
120
	private JCheckBox useKeepAlive;
100
121
101
	/*
122
	/**
102
	 * Use regexes to match the source data
123
	 * Set/clear the Download images box on the samplers (default is false)
103
	 */
124
	 */
104
	private JCheckBox regexMatch;
125
	private JCheckBox samplerDownloadImages;
105
126
106
	/*
127
	/*
107
	 * Spoof the client into thinking that it is communicating with http
128
	 * Spoof the client into thinking that it is communicating with http
Lines 181-187 Link Here
181
			model.setCaptureHttpHeaders(httpHeaders.isSelected());
202
			model.setCaptureHttpHeaders(httpHeaders.isSelected());
182
			model.setGroupingMode(groupingMode.getSelectedIndex());
203
			model.setGroupingMode(groupingMode.getSelectedIndex());
183
			model.setAssertions(addAssertions.isSelected());
204
			model.setAssertions(addAssertions.isSelected());
205
			model.setSamplerTypeName(samplerTypeName.getSelectedIndex());
206
			model.setSamplerRedirectAutomatically(samplerRedirectAutomatically.isSelected());
207
			model.setSamplerFollowRedirects(samplerFollowRedirects.isSelected());
184
			model.setUseKeepAlive(useKeepAlive.isSelected());
208
			model.setUseKeepAlive(useKeepAlive.isSelected());
209
			model.setSamplerDownloadImages(samplerDownloadImages.isSelected());
185
			model.setRegexMatch(regexMatch.isSelected());
210
			model.setRegexMatch(regexMatch.isSelected());
186
			model.setHttpsSpoof(httpsSpoof.isSelected());			
211
			model.setHttpsSpoof(httpsSpoof.isSelected());			
187
			TreeNodeWrapper nw = (TreeNodeWrapper) targetNodes.getSelectedItem();
212
			TreeNodeWrapper nw = (TreeNodeWrapper) targetNodes.getSelectedItem();
Lines 228-234 Link Here
228
		httpHeaders.setSelected(model.getCaptureHttpHeaders());
253
		httpHeaders.setSelected(model.getCaptureHttpHeaders());
229
		groupingMode.setSelectedIndex(model.getGroupingMode());
254
		groupingMode.setSelectedIndex(model.getGroupingMode());
230
		addAssertions.setSelected(model.getAssertions());
255
		addAssertions.setSelected(model.getAssertions());
256
		samplerTypeName.setSelectedIndex(model.getSamplerTypeName());
257
		samplerRedirectAutomatically.setSelected(model.getSamplerRedirectAutomatically());
258
		samplerFollowRedirects.setSelected(model.getSamplerFollowRedirects());
231
		useKeepAlive.setSelected(model.getUseKeepalive());
259
		useKeepAlive.setSelected(model.getUseKeepalive());
260
		samplerDownloadImages.setSelected(model.getSamplerDownloadImages());
232
		regexMatch.setSelected(model.getRegexMatch());
261
		regexMatch.setSelected(model.getRegexMatch());
233
		httpsSpoof.setSelected(model.getHttpsSpoof());
262
		httpsSpoof.setSelected(model.getHttpsSpoof());
234
263
Lines 290-297 Link Here
290
			model.stopProxy();
319
			model.stopProxy();
291
			startProxy();
320
			startProxy();
292
		} else if (command.equals(ProxyControl.CAPTURE_HTTP_HEADERS) || command.equals(ProxyControl.ADD_ASSERTIONS)
321
		} else if (command.equals(ProxyControl.CAPTURE_HTTP_HEADERS) || command.equals(ProxyControl.ADD_ASSERTIONS)
293
				|| command.equals(ProxyControl.USE_KEEPALIVE) || command.equals(ProxyControl.REGEX_MATCH)
322
				|| command.equals(ProxyControl.SAMPLER_REDIRECT_AUTOMATICALLY)  
294
				|| command.equals(ProxyControl.HTTPS_SPOOF)) {
323
				|| command.equals(ProxyControl.SAMPLER_FOLLOW_REDIRECTS) 
324
				|| command.equals(ProxyControl.USE_KEEPALIVE) || command.equals(ProxyControl.SAMPLER_DOWNLOAD_IMAGES) 
325
				|| command.equals(ProxyControl.REGEX_MATCH) || command.equals(ProxyControl.HTTPS_SPOOF)) {
295
			enableRestart();
326
			enableRestart();
296
		} else if (command.equals(ADD_EXCLUDE)) {
327
		} else if (command.equals(ADD_EXCLUDE)) {
297
			excludeModel.addNewRow();
328
			excludeModel.addNewRow();
Lines 400-405 Link Here
400
		Box myBox = Box.createVerticalBox();
431
		Box myBox = Box.createVerticalBox();
401
		myBox.add(createPortPanel());
432
		myBox.add(createPortPanel());
402
		myBox.add(Box.createVerticalStrut(5));
433
		myBox.add(Box.createVerticalStrut(5));
434
		myBox.add(createTestPlanContentPanel());
435
		myBox.add(Box.createVerticalStrut(5));
436
		myBox.add(createHTTPSamplerPanel());
437
		myBox.add(Box.createVerticalStrut(5));
403
		myBox.add(createTargetPanel());
438
		myBox.add(createTargetPanel());
404
		myBox.add(Box.createVerticalStrut(5));
439
		myBox.add(Box.createVerticalStrut(5));
405
		myBox.add(createGroupingPanel());
440
		myBox.add(createGroupingPanel());
Lines 447-452 Link Here
447
		JLabel label = new JLabel(JMeterUtils.getResString("port"));
482
		JLabel label = new JLabel(JMeterUtils.getResString("port"));
448
		label.setLabelFor(portField);
483
		label.setLabelFor(portField);
449
484
485
		httpsSpoof = new JCheckBox(JMeterUtils.getResString("proxy_httpsspoofing"));
486
		httpsSpoof.setName(ProxyControl.HTTPS_SPOOF);
487
		httpsSpoof.setSelected(false);
488
		httpsSpoof.addActionListener(this);
489
		httpsSpoof.setActionCommand(ProxyControl.HTTPS_SPOOF);		
490
		
491
		HorizontalPanel panel = new HorizontalPanel();
492
		panel.add(label);
493
		panel.add(portField);
494
495
		panel.add(Box.createHorizontalStrut(10));
496
		panel.add(httpsSpoof);
497
498
		return panel;
499
	}
500
501
	private JPanel createTestPlanContentPanel() {
502
		JLabel label = new JLabel("Test plan content:");
503
450
		httpHeaders = new JCheckBox(JMeterUtils.getResString("proxy_headers"));
504
		httpHeaders = new JCheckBox(JMeterUtils.getResString("proxy_headers"));
451
		httpHeaders.setName(ProxyControl.CAPTURE_HTTP_HEADERS);
505
		httpHeaders.setName(ProxyControl.CAPTURE_HTTP_HEADERS);
452
		httpHeaders.setSelected(true); // maintain original default
506
		httpHeaders.setSelected(true); // maintain original default
Lines 459-497 Link Here
459
		addAssertions.addActionListener(this);
513
		addAssertions.addActionListener(this);
460
		addAssertions.setActionCommand(ProxyControl.ADD_ASSERTIONS);
514
		addAssertions.setActionCommand(ProxyControl.ADD_ASSERTIONS);
461
515
462
		useKeepAlive = new JCheckBox(JMeterUtils.getResString("proxy_usekeepalive"));
463
		useKeepAlive.setName(ProxyControl.USE_KEEPALIVE);
464
		useKeepAlive.setSelected(true);
465
		useKeepAlive.addActionListener(this);
466
		useKeepAlive.setActionCommand(ProxyControl.USE_KEEPALIVE);
467
468
		regexMatch = new JCheckBox(JMeterUtils.getResString("proxy_regex"));
516
		regexMatch = new JCheckBox(JMeterUtils.getResString("proxy_regex"));
469
		regexMatch.setName(ProxyControl.REGEX_MATCH);
517
		regexMatch.setName(ProxyControl.REGEX_MATCH);
470
		regexMatch.setSelected(false);
518
		regexMatch.setSelected(false);
471
		regexMatch.addActionListener(this);
519
		regexMatch.addActionListener(this);
472
		regexMatch.setActionCommand(ProxyControl.REGEX_MATCH);
520
		regexMatch.setActionCommand(ProxyControl.REGEX_MATCH);
473
521
474
		httpsSpoof = new JCheckBox(JMeterUtils.getResString("proxy_httpsspoofing"));
475
		httpsSpoof.setName(ProxyControl.HTTPS_SPOOF);
476
		httpsSpoof.setSelected(false);
477
		httpsSpoof.addActionListener(this);
478
		httpsSpoof.setActionCommand(ProxyControl.HTTPS_SPOOF);		
479
		
480
		HorizontalPanel panel = new HorizontalPanel();
522
		HorizontalPanel panel = new HorizontalPanel();
481
		panel.add(label);
523
		panel.add(label);
482
		panel.add(portField);
483
524
484
		panel.add(Box.createHorizontalStrut(10));
485
		panel.add(httpHeaders);
525
		panel.add(httpHeaders);
486
487
		panel.add(useKeepAlive);
488
		panel.add(addAssertions);
526
		panel.add(addAssertions);
489
		panel.add(regexMatch);
527
		panel.add(regexMatch);
490
		panel.add(httpsSpoof);
491
528
492
		return panel;
529
		return panel;
493
	}
530
	}
494
531
532
	private JPanel createHTTPSamplerPanel() {
533
		JLabel label = new JLabel("HTTP Sampler settings:");
534
		
535
		DefaultComboBoxModel m = new DefaultComboBoxModel();
536
		// Note: position of these elements in the menu *must* match the
537
		// corresponding ProxyControl.SAMPLER_TYPE_* values.
538
		m.addElement(JMeterUtils.getResString("web_request"));
539
		m.addElement(JMeterUtils.getResString("web_request") + " HTTPClient");
540
		samplerTypeName = new JComboBox(m);
541
		samplerTypeName.setName(ProxyControl.SAMPLER_TYPE_NAME);
542
		samplerTypeName.setSelectedIndex(0);
543
		samplerTypeName.addItemListener(this);
544
		JLabel label2 = new JLabel("Type:");
545
		label2.setLabelFor(samplerTypeName);
546
547
		samplerRedirectAutomatically = new JCheckBox("Redirect automatically");
548
		samplerRedirectAutomatically.setName(ProxyControl.SAMPLER_REDIRECT_AUTOMATICALLY);
549
		samplerRedirectAutomatically.setSelected(false);
550
		samplerRedirectAutomatically.addActionListener(this);
551
		samplerRedirectAutomatically.setActionCommand(ProxyControl.SAMPLER_REDIRECT_AUTOMATICALLY);
552
		
553
		samplerFollowRedirects = new JCheckBox("Follow redirects");
554
		samplerFollowRedirects.setName(ProxyControl.SAMPLER_FOLLOW_REDIRECTS);
555
		samplerFollowRedirects.setSelected(true);
556
		samplerFollowRedirects.addActionListener(this);
557
		samplerFollowRedirects.setActionCommand(ProxyControl.SAMPLER_FOLLOW_REDIRECTS);
558
		
559
		useKeepAlive = new JCheckBox(JMeterUtils.getResString("proxy_usekeepalive"));
560
		useKeepAlive.setName(ProxyControl.USE_KEEPALIVE);
561
		useKeepAlive.setSelected(true);
562
		useKeepAlive.addActionListener(this);
563
		useKeepAlive.setActionCommand(ProxyControl.USE_KEEPALIVE);
564
565
		samplerDownloadImages = new JCheckBox("Download images");
566
		samplerDownloadImages.setName(ProxyControl.SAMPLER_DOWNLOAD_IMAGES);
567
		samplerDownloadImages.setSelected(false);
568
		samplerDownloadImages.addActionListener(this);
569
		samplerDownloadImages.setActionCommand(ProxyControl.SAMPLER_DOWNLOAD_IMAGES);
570
		
571
		HorizontalPanel panel = new HorizontalPanel();
572
		panel.add(label);
573
		panel.add(label2);
574
		panel.add(samplerTypeName);
575
		panel.add(samplerRedirectAutomatically);
576
		panel.add(samplerFollowRedirects);
577
		panel.add(useKeepAlive);
578
		panel.add(samplerDownloadImages);
579
580
		return panel;
581
	}
582
	
495
	private JPanel createTargetPanel() {
583
	private JPanel createTargetPanel() {
496
		targetNodesModel = new DefaultComboBoxModel();
584
		targetNodesModel = new DefaultComboBoxModel();
497
		targetNodes = new JComboBox(targetNodesModel);
585
		targetNodes = new JComboBox(targetNodesModel);
Lines 560-566 Link Here
560
	private JPanel createIncludePanel() {
648
	private JPanel createIncludePanel() {
561
		includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class });
649
		includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class });
562
		includeTable = new JTable(includeModel);
650
		includeTable = new JTable(includeModel);
563
		includeTable.setPreferredScrollableViewportSize(new Dimension(100, 50));
651
		includeTable.setPreferredScrollableViewportSize(new Dimension(100, 30));
564
		includeTable.addFocusListener(this);
652
		includeTable.addFocusListener(this);
565
653
566
		JPanel panel = new JPanel(new BorderLayout());
654
		JPanel panel = new JPanel(new BorderLayout());
Lines 576-582 Link Here
576
	private JPanel createExcludePanel() {
664
	private JPanel createExcludePanel() {
577
		excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class });
665
		excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class });
578
		excludeTable = new JTable(excludeModel);
666
		excludeTable = new JTable(excludeModel);
579
		excludeTable.setPreferredScrollableViewportSize(new Dimension(100, 50));
667
		excludeTable.setPreferredScrollableViewportSize(new Dimension(100, 30));
580
		excludeTable.addFocusListener(this);
668
		excludeTable.addFocusListener(this);
581
669
582
		JPanel panel = new JPanel(new BorderLayout());
670
		JPanel panel = new JPanel(new BorderLayout());
(-)C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java (-11 / +37 lines)
Lines 32-38 Link Here
32
import org.apache.jmeter.protocol.http.control.Header;
32
import org.apache.jmeter.protocol.http.control.Header;
33
import org.apache.jmeter.protocol.http.control.HeaderManager;
33
import org.apache.jmeter.protocol.http.control.HeaderManager;
34
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
34
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
35
import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui2;
35
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
36
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
37
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
38
import org.apache.jmeter.protocol.http.sampler.HTTPSampler2;
36
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
39
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
37
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
40
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
38
import org.apache.jmeter.testelement.TestElement;
41
import org.apache.jmeter.testelement.TestElement;
Lines 75-80 Link Here
75
78
76
	private Map headers = new HashMap();
79
	private Map headers = new HashMap();
77
80
81
	private HTTPSamplerBase sampler;
82
78
	/*
83
	/*
79
	 * Optionally number the requests
84
	 * Optionally number the requests
80
	 */
85
	 */
Lines 83-89 Link Here
83
88
84
	private static int requestNumber = 0;// running number
89
	private static int requestNumber = 0;// running number
85
90
91
	public HttpRequestHdr() {
92
		this.sampler = HTTPSamplerFactory.newInstance();
93
	}
94
	
86
	/**
95
	/**
96
	 * @param samplerTypeName the name of the http sampler to instantiate, as defined in HTTPSamplerFactory
97
	 */
98
	public HttpRequestHdr(HTTPSamplerBase sampler) {
99
		this.sampler = sampler;
100
	}
101
	
102
	/**
87
	 * Parses a http header from a stream.
103
	 * Parses a http header from a stream.
88
	 * 
104
	 * 
89
	 * @param in
105
	 * @param in
Lines 179-193 Link Here
179
	public HTTPSamplerBase getSampler() throws MalformedURLException, IOException, ProtocolException {
195
	public HTTPSamplerBase getSampler() throws MalformedURLException, IOException, ProtocolException {
180
		// Damn! A whole new GUI just to instantiate a test element?
196
		// Damn! A whole new GUI just to instantiate a test element?
181
		// Isn't there a beter way?
197
		// Isn't there a beter way?
182
		HttpTestSampleGui tempGui = new HttpTestSampleGui();
198
		HttpTestSampleGui tempGui = null;
183
		HTTPSamplerBase result = createSampler();
199
		// Create the corresponding gui for the sampler class
184
		tempGui.configure(result);
200
		if(sampler instanceof HTTPSampler2) {
185
		tempGui.modifyTestElement(result);
201
			tempGui = new HttpTestSampleGui2();
186
		result.setFollowRedirects(false);
202
		}
187
		result.setUseKeepAlive(true);
203
		else {
204
			tempGui = new HttpTestSampleGui();
205
		}
206
		sampler.setProperty(TestElement.GUI_CLASS, tempGui.getClass().getName());
207
		populateSampler();
208
		
209
		tempGui.configure(sampler);
210
		tempGui.modifyTestElement(sampler);
211
		// Defaults
212
		sampler.setFollowRedirects(false);
213
		sampler.setUseKeepAlive(true);
214
		
188
        if (log.isDebugEnabled())
215
        if (log.isDebugEnabled())
189
    		log.debug("getSampler: sampler path = " + result.getPath());
216
    		log.debug("getSampler: sampler path = " + sampler.getPath());
190
		return result;
217
		return sampler;
191
	}
218
	}
192
219
193
	private String getContentType() {
220
	private String getContentType() {
Lines 206-214 Link Here
206
		}
233
		}
207
	}
234
	}
208
235
209
	private HTTPSamplerBase createSampler() {
236
	private void populateSampler() {
210
		MultipartUrlConfig urlConfig = null;
237
		MultipartUrlConfig urlConfig = null;
211
		HTTPSamplerBase sampler = HTTPSamplerFactory.newInstance();
238
		
212
		sampler.setDomain(serverName());
239
		sampler.setDomain(serverName());
213
        if (log.isDebugEnabled())
240
        if (log.isDebugEnabled())
214
    		log.debug("Proxy: setting server: " + sampler.getDomain());
241
    		log.debug("Proxy: setting server: " + sampler.getDomain());
Lines 253-259 Link Here
253
		}
280
		}
254
        if (log.isDebugEnabled())
281
        if (log.isDebugEnabled())
255
    		log.debug("sampler path = " + sampler.getPath());
282
    		log.debug("sampler path = " + sampler.getPath());
256
		return sampler;
257
	}
283
	}
258
284
259
	//
285
	//

Return to bug 41876