Lines 38-44
import java.util.List;
Link Here
|
38 |
import java.util.Map; |
38 |
import java.util.Map; |
39 |
import java.util.Set; |
39 |
import java.util.Set; |
40 |
|
40 |
|
41 |
import javax.activation.MimetypesFileTypeMap; |
|
|
42 |
import javax.swing.JButton; |
41 |
import javax.swing.JButton; |
43 |
import javax.swing.JCheckBox; |
42 |
import javax.swing.JCheckBox; |
44 |
import javax.swing.JLabel; |
43 |
import javax.swing.JLabel; |
Lines 52-57
import javax.swing.tree.TreePath;
Link Here
|
52 |
|
51 |
|
53 |
import org.apache.commons.io.FileUtils; |
52 |
import org.apache.commons.io.FileUtils; |
54 |
import org.apache.commons.lang3.StringUtils; |
53 |
import org.apache.commons.lang3.StringUtils; |
|
|
54 |
import org.apache.commons.lang3.tuple.Pair; |
55 |
import org.apache.jmeter.config.Arguments; |
55 |
import org.apache.jmeter.config.Arguments; |
56 |
import org.apache.jmeter.config.KeystoreConfig; |
56 |
import org.apache.jmeter.config.KeystoreConfig; |
57 |
import org.apache.jmeter.control.Controller; |
57 |
import org.apache.jmeter.control.Controller; |
Lines 101-106
import org.apache.jmeter.visualizers.ViewResultsFullVisualizer;
Link Here
|
101 |
import org.apache.jorphan.collections.HashTree; |
101 |
import org.apache.jorphan.collections.HashTree; |
102 |
import org.apache.jorphan.gui.ComponentUtil; |
102 |
import org.apache.jorphan.gui.ComponentUtil; |
103 |
import org.apache.jorphan.gui.JMeterUIDefaults; |
103 |
import org.apache.jorphan.gui.JMeterUIDefaults; |
|
|
104 |
import org.apache.tika.Tika; |
104 |
import org.slf4j.Logger; |
105 |
import org.slf4j.Logger; |
105 |
import org.slf4j.LoggerFactory; |
106 |
import org.slf4j.LoggerFactory; |
106 |
|
107 |
|
Lines 118-123
public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
Link Here
|
118 |
private static final String CREATE_REQUEST = "CREATE_REQUEST"; |
119 |
private static final String CREATE_REQUEST = "CREATE_REQUEST"; |
119 |
private static final String TYPE_FORM = ";type="; |
120 |
private static final String TYPE_FORM = ";type="; |
120 |
private static final String CERT = "cert"; |
121 |
private static final String CERT = "cert"; |
|
|
122 |
private Logger log = LoggerFactory.getLogger(getClass()); |
121 |
/** A panel allowing results to be saved. */ |
123 |
/** A panel allowing results to be saved. */ |
122 |
private FilePanel filePanel = null; |
124 |
private FilePanel filePanel = null; |
123 |
static { |
125 |
static { |
Lines 126-131
public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
Link Here
|
126 |
private JSyntaxTextArea cURLCommandTA; |
128 |
private JSyntaxTextArea cURLCommandTA; |
127 |
private JLabel statusText; |
129 |
private JLabel statusText; |
128 |
private JCheckBox uploadCookiesCheckBox; |
130 |
private JCheckBox uploadCookiesCheckBox; |
|
|
131 |
private final Tika tika = new Tika(); |
129 |
public ParseCurlCommandAction() { |
132 |
public ParseCurlCommandAction() { |
130 |
super(); |
133 |
super(); |
131 |
} |
134 |
} |
Lines 344-352
public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
Link Here
|
344 |
headerManager.setProperty(TestElement.GUI_CLASS, HeaderPanel.class.getName()); |
347 |
headerManager.setProperty(TestElement.GUI_CLASS, HeaderPanel.class.getName()); |
345 |
headerManager.setProperty(TestElement.NAME, "HTTP HeaderManager"); |
348 |
headerManager.setProperty(TestElement.NAME, "HTTP HeaderManager"); |
346 |
headerManager.setProperty(TestElement.COMMENTS, getDefaultComment()); |
349 |
headerManager.setProperty(TestElement.COMMENTS, getDefaultComment()); |
347 |
Map<String, String> map = request.getHeaders(); |
|
|
348 |
boolean hasAcceptEncoding = false; |
350 |
boolean hasAcceptEncoding = false; |
349 |
for (Map.Entry<String, String> header : map.entrySet()) { |
351 |
for (Pair<String, String> header : request.getHeaders()) { |
350 |
String key = header.getKey(); |
352 |
String key = header.getKey(); |
351 |
hasAcceptEncoding = hasAcceptEncoding || key.equalsIgnoreCase(ACCEPT_ENCODING); |
353 |
hasAcceptEncoding = hasAcceptEncoding || key.equalsIgnoreCase(ACCEPT_ENCODING); |
352 |
headerManager.getHeaders().addItem(new Header(key, header.getValue())); |
354 |
headerManager.getHeaders().addItem(new Header(key, header.getValue())); |
Lines 515-526
public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
Link Here
|
515 |
throw new IllegalArgumentException("--form and --data can't appear in the same command"); |
517 |
throw new IllegalArgumentException("--form and --data can't appear in the same command"); |
516 |
} |
518 |
} |
517 |
List<HTTPFileArg> httpFileArgs = new ArrayList<>(); |
519 |
List<HTTPFileArg> httpFileArgs = new ArrayList<>(); |
518 |
for (Map.Entry<String, String> entry : request.getFormStringData().entrySet()) { |
520 |
for (Pair<String, String> entry : request.getFormStringData()) { |
519 |
String formName = entry.getKey(); |
521 |
String formName = entry.getKey(); |
520 |
String formValue = entry.getValue(); |
522 |
String formValue = entry.getValue(); |
521 |
httpSampler.addNonEncodedArgument(formName, formValue, ""); |
523 |
httpSampler.addNonEncodedArgument(formName, formValue, ""); |
522 |
} |
524 |
} |
523 |
for (Map.Entry<String, String> entry : request.getFormData().entrySet()) { |
525 |
for (Pair<String, String> entry : request.getFormData()) { |
524 |
String formName = entry.getKey(); |
526 |
String formName = entry.getKey(); |
525 |
String formValue = entry.getValue(); |
527 |
String formValue = entry.getValue(); |
526 |
boolean isContainsFile = "@".equals(formValue.substring(0, 1)); |
528 |
boolean isContainsFile = "@".equals(formValue.substring(0, 1)); |
Lines 533-539
public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
Link Here
|
533 |
formValue = formValueWithType[0]; |
535 |
formValue = formValueWithType[0]; |
534 |
contentType = formValueWithType[1]; |
536 |
contentType = formValueWithType[1]; |
535 |
} else { |
537 |
} else { |
536 |
contentType = new MimetypesFileTypeMap().getContentType(formValue); |
538 |
try { |
|
|
539 |
contentType = tika.detect(new File(formValue)); |
540 |
} catch (IOException e) { |
541 |
log.info("Could not detect contentType for file {} by content, so falling back to detection by filename"); |
542 |
contentType = tika.detect(formValue); |
543 |
} |
537 |
} |
544 |
} |
538 |
httpFileArgs.add(new HTTPFileArg(formValue, formName, contentType)); |
545 |
httpFileArgs.add(new HTTPFileArg(formValue, formName, contentType)); |
539 |
} else { |
546 |
} else { |
540 |
- |
|
|