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

(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java (-3 / +3 lines)
Lines 23-29 Link Here
23
import java.io.IOException;
23
import java.io.IOException;
24
import java.io.InputStream;
24
import java.io.InputStream;
25
import java.io.OutputStream;
25
import java.io.OutputStream;
26
import java.io.PrintWriter;
26
import java.io.OutputStreamWriter;
27
import java.io.UnsupportedEncodingException;
27
import java.io.UnsupportedEncodingException;
28
import java.net.HttpURLConnection;
28
import java.net.HttpURLConnection;
29
import java.net.URLConnection;
29
import java.net.URLConnection;
Lines 87-94 Link Here
87
		// No filename specified, so send the post using normal syntax
87
		// No filename specified, so send the post using normal syntax
88
		else {
88
		else {
89
			String postData = sampler.getQueryString();
89
			String postData = sampler.getQueryString();
90
			PrintWriter out = new PrintWriter(connection.getOutputStream());
90
			OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), sampler.getContentEncoding());
91
			out.print(postData);
91
			out.write(postData);
92
			out.flush();
92
			out.flush();
93
            out.close();
93
            out.close();
94
		}
94
		}
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (-2 / +9 lines)
Lines 227-236 Link Here
227
	 * 
227
	 * 
228
	 * @param connection
228
	 * @param connection
229
	 *            <code>URLConnection</code> where POST data should be sent
229
	 *            <code>URLConnection</code> where POST data should be sent
230
	 * @param contentEncoding
231
	 *            the character set encoding used for sending POST data
230
	 * @exception IOException
232
	 * @exception IOException
231
	 *                if an I/O exception occurs
233
	 *                if an I/O exception occurs
232
	 */
234
	 */
233
	private void sendPostData(PostMethod post) throws IOException {
235
	private void sendPostData(PostMethod post, String contentEncoding) throws IOException {
234
		// If filename was specified then send the post using multipart syntax
236
		// If filename was specified then send the post using multipart syntax
235
		String filename = getFilename();
237
		String filename = getFilename();
236
		if ((filename != null) && (filename.trim().length() > 0)) {
238
		if ((filename != null) && (filename.trim().length() > 0)) {
Lines 251-256 Link Here
251
	            post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
253
	            post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
252
			}
254
			}
253
		} else {
255
		} else {
256
            // If a content encoding is specified, we set it as http parameter, so that
257
            // the post body will be encoded in the specified content encoding
258
            if(contentEncoding != null && contentEncoding.trim().length() > 0) {
259
    			post.getParams().setContentCharset(contentEncoding);
260
            }
254
            PropertyIterator args = getArguments().iterator();
261
            PropertyIterator args = getArguments().iterator();
255
            while (args.hasNext()) {
262
            while (args.hasNext()) {
256
                Argument arg = (Argument) args.next().getObjectValue();
263
                Argument arg = (Argument) args.next().getObjectValue();
Lines 561-567 Link Here
561
568
562
			if (method.equals(POST)) {
569
			if (method.equals(POST)) {
563
                res.setQueryString(getQueryString());
570
                res.setQueryString(getQueryString());
564
				sendPostData((PostMethod)httpMethod);
571
				sendPostData((PostMethod)httpMethod, getContentEncoding());
565
			} else if (method.equals(PUT)) {
572
			} else if (method.equals(PUT)) {
566
                setPutHeaders((PutMethod) httpMethod);
573
                setPutHeaders((PutMethod) httpMethod);
567
            }
574
            }
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (+10 lines)
Lines 82-87 Link Here
82
82
83
	public final static String METHOD = "HTTPSampler.method"; // $NON-NLS-1$
83
	public final static String METHOD = "HTTPSampler.method"; // $NON-NLS-1$
84
84
85
	public final static String CONTENT_ENCODING = "HTTPSampler.contentEncoding"; // $NON-NLS-1$
86
85
    public final static String IMPLEMENTATION = "HTTPSampler.implementation"; // $NON-NLS-1$
87
    public final static String IMPLEMENTATION = "HTTPSampler.implementation"; // $NON-NLS-1$
86
88
87
    public final static String PATH = "HTTPSampler.path"; // $NON-NLS-1$
89
    public final static String PATH = "HTTPSampler.path"; // $NON-NLS-1$
Lines 343-348 Link Here
343
		return getPropertyAsString(METHOD);
345
		return getPropertyAsString(METHOD);
344
	}
346
	}
345
347
348
	public void setContentEncoding(String value) {
349
		setProperty(CONTENT_ENCODING, value);
350
	}
351
352
	public String getContentEncoding() {
353
		return getPropertyAsString(CONTENT_ENCODING);
354
	}
355
346
	public void setUseKeepAlive(boolean value) {
356
	public void setUseKeepAlive(boolean value) {
347
		setProperty(new BooleanProperty(USE_KEEPALIVE, value));
357
		setProperty(new BooleanProperty(USE_KEEPALIVE, value));
348
	}
358
	}
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java (-1 / +16 lines)
Lines 54-59 Link Here
54
54
55
	private static String PROTOCOL = "protocol"; // $NON-NLS-1$
55
	private static String PROTOCOL = "protocol"; // $NON-NLS-1$
56
56
57
	private static String CONTENT_ENCODING = "content_encoding"; // $NON-NLS-1$
58
57
	private static String PATH = "path"; // $NON-NLS-1$
59
	private static String PATH = "path"; // $NON-NLS-1$
58
60
59
	private static String FOLLOW_REDIRECTS = "follow_redirects"; // $NON-NLS-1$
61
	private static String FOLLOW_REDIRECTS = "follow_redirects"; // $NON-NLS-1$
Lines 68-73 Link Here
68
70
69
	private JTextField protocol;
71
	private JTextField protocol;
70
72
73
	private JTextField contentEncoding;
74
71
	private JTextField path;
75
	private JTextField path;
72
76
73
	private JCheckBox followRedirects;
77
	private JCheckBox followRedirects;
Lines 96-104 Link Here
96
		path.setText(""); // $NON-NLS-1$
100
		path.setText(""); // $NON-NLS-1$
97
		port.setText(""); // $NON-NLS-1$
101
		port.setText(""); // $NON-NLS-1$
98
		protocol.setText(""); // $NON-NLS-1$
102
		protocol.setText(""); // $NON-NLS-1$
103
		contentEncoding.setText(""); // $NON-NLS-1$
99
		useKeepAlive.setSelected(true);
104
		useKeepAlive.setSelected(true);
100
		argsPanel.clear();
105
		argsPanel.clear();
101
102
	}
106
	}
103
107
104
	public TestElement createTestElement() {
108
	public TestElement createTestElement() {
Lines 113-118 Link Here
113
		element.setProperty(HTTPSamplerBase.PORT, port.getText());
117
		element.setProperty(HTTPSamplerBase.PORT, port.getText());
114
		element.setProperty(HTTPSamplerBase.PROTOCOL, protocol.getText());
118
		element.setProperty(HTTPSamplerBase.PROTOCOL, protocol.getText());
115
		element.setProperty(HTTPSamplerBase.METHOD, method.getText());
119
		element.setProperty(HTTPSamplerBase.METHOD, method.getText());
120
		element.setProperty(HTTPSamplerBase.CONTENT_ENCODING, contentEncoding.getText());
116
		element.setProperty(HTTPSamplerBase.PATH, path.getText());
121
		element.setProperty(HTTPSamplerBase.PATH, path.getText());
117
		element.setProperty(new BooleanProperty(HTTPSamplerBase.FOLLOW_REDIRECTS, followRedirects.isSelected()));
122
		element.setProperty(new BooleanProperty(HTTPSamplerBase.FOLLOW_REDIRECTS, followRedirects.isSelected()));
118
		element.setProperty(new BooleanProperty(HTTPSamplerBase.AUTO_REDIRECTS, autoRedirects.isSelected()));
123
		element.setProperty(new BooleanProperty(HTTPSamplerBase.AUTO_REDIRECTS, autoRedirects.isSelected()));
Lines 141-146 Link Here
141
		}
146
		}
142
		protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
147
		protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
143
        method.setText(el.getPropertyAsString(HTTPSamplerBase.METHOD));
148
        method.setText(el.getPropertyAsString(HTTPSamplerBase.METHOD));
149
        contentEncoding.setText(el.getPropertyAsString(HTTPSamplerBase.CONTENT_ENCODING));
144
		path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
150
		path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
145
		followRedirects.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.FOLLOW_REDIRECTS));
151
		followRedirects.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.FOLLOW_REDIRECTS));
146
152
Lines 251-259 Link Here
251
		// PROTOCOL
257
		// PROTOCOL
252
		protocol = new JTextField(20);
258
		protocol = new JTextField(20);
253
		protocol.setName(PROTOCOL);
259
		protocol.setName(PROTOCOL);
260
		// CONTENT_ENCODING
261
		contentEncoding = new JTextField(10);
262
		contentEncoding.setName(CONTENT_ENCODING);
254
263
255
		JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
264
		JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
256
		protocolLabel.setLabelFor(protocol);
265
		protocolLabel.setLabelFor(protocol);
266
		JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
267
		protocolLabel.setLabelFor(contentEncoding);
257
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
268
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
258
                HTTPSamplerBase.getValidMethodsAsArray());
269
                HTTPSamplerBase.getValidMethodsAsArray());
259
270
Lines 265-270 Link Here
265
276
266
        panel.add(method);
277
        panel.add(method);
267
		panel.setMinimumSize(panel.getPreferredSize());
278
		panel.setMinimumSize(panel.getPreferredSize());
279
        panel.add(Box.createHorizontalStrut(5));
280
		
281
		panel.add(contentEncodingLabel);
282
		panel.add(contentEncoding);
268
		return panel;
283
		return panel;
269
	}
284
	}
270
285
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/core/org/apache/jmeter/resources/messages.properties (+1 lines)
Lines 100-105 Link Here
100
constant_timer_delay=Thread Delay (in milliseconds)\:
100
constant_timer_delay=Thread Delay (in milliseconds)\:
101
constant_timer_memo=Add a constant delay between sampling
101
constant_timer_memo=Add a constant delay between sampling
102
constant_timer_title=Constant Timer
102
constant_timer_title=Constant Timer
103
content_encoding=Content encoding\:
103
controller=Controller
104
controller=Controller
104
cookie_manager_policy=Cookie Policy
105
cookie_manager_policy=Cookie Policy
105
cookie_manager_title=HTTP Cookie Manager
106
cookie_manager_title=HTTP Cookie Manager

Return to bug 41705