Lines 16-21
Link Here
|
16 |
*/ |
16 |
*/ |
17 |
package org.apache.jmeter.protocol.http.sampler; |
17 |
package org.apache.jmeter.protocol.http.sampler; |
18 |
|
18 |
|
|
|
19 |
import java.io.ByteArrayInputStream; |
19 |
import java.io.ByteArrayOutputStream; |
20 |
import java.io.ByteArrayOutputStream; |
20 |
import java.io.IOException; |
21 |
import java.io.IOException; |
21 |
import java.io.PrintStream; |
22 |
import java.io.PrintStream; |
Lines 52-57
Link Here
|
52 |
import org.apache.jorphan.logging.LoggingManager; |
53 |
import org.apache.jorphan.logging.LoggingManager; |
53 |
import org.apache.jorphan.util.JOrphanUtils; |
54 |
import org.apache.jorphan.util.JOrphanUtils; |
54 |
import org.apache.log.Logger; |
55 |
import org.apache.log.Logger; |
|
|
56 |
import org.apache.xerces.parsers.DOMParser; |
57 |
import org.xml.sax.InputSource; |
55 |
|
58 |
|
56 |
/** |
59 |
/** |
57 |
* Common constants and methods for HTTP samplers |
60 |
* Common constants and methods for HTTP samplers |
Lines 229-234
Link Here
|
229 |
} |
232 |
} |
230 |
} |
233 |
} |
231 |
|
234 |
|
|
|
235 |
//variables used for xml-rpc call handling |
236 |
public static DOMParser xmlRpcParser = null; |
237 |
public static XmlRpcErrorHandler xmlRpcErrorHandler = null; |
238 |
|
232 |
////////////////////// Variables ////////////////////// |
239 |
////////////////////// Variables ////////////////////// |
233 |
|
240 |
|
234 |
private boolean dynamicPath = false;// Set false if spaces are already encoded |
241 |
private boolean dynamicPath = false;// Set false if spaces are already encoded |
Lines 396-401
Link Here
|
396 |
this.getArguments().addArgument(arg); |
403 |
this.getArguments().addArgument(arg); |
397 |
} |
404 |
} |
398 |
|
405 |
|
|
|
406 |
public void addUnencodedArgument(String name, String value, String metadata) { |
407 |
HTTPArgument arg = new HTTPArgument(name, value, metadata, false); |
408 |
arg.setAlwaysEncoded(false); |
409 |
this.getArguments().addArgument(arg); |
410 |
} |
411 |
|
399 |
public void addArgument(String name, String value) { |
412 |
public void addArgument(String name, String value) { |
400 |
this.getArguments().addArgument(new HTTPArgument(name, value)); |
413 |
this.getArguments().addArgument(new HTTPArgument(name, value)); |
401 |
} |
414 |
} |
Lines 618-657
Link Here
|
618 |
* |
631 |
* |
619 |
*/ |
632 |
*/ |
620 |
public void parseArguments(String queryString) { |
633 |
public void parseArguments(String queryString) { |
621 |
String[] args = JOrphanUtils.split(queryString, QRY_SEP); |
634 |
if (isXmlRpc(queryString)) { |
622 |
for (int i = 0; i < args.length; i++) { |
635 |
addUnencodedArgument("", queryString, ""); |
623 |
// need to handle four cases: |
636 |
} else { |
624 |
// - string contains name=value |
637 |
String[] args = JOrphanUtils.split(queryString, QRY_SEP); |
625 |
// - string contains name= |
638 |
for (int i = 0; i < args.length; i++) { |
626 |
// - string contains name |
639 |
// need to handle four cases: |
627 |
// - empty string |
640 |
// - string contains name=value |
628 |
|
641 |
// - string contains name= |
629 |
String metaData; // records the existance of an equal sign |
642 |
// - string contains name |
630 |
String name; |
643 |
// - empty string |
631 |
String value; |
644 |
|
632 |
int length = args[i].length(); |
645 |
String metaData; // records the existance of an equal sign |
633 |
int endOfNameIndex = args[i].indexOf(ARG_VAL_SEP); |
646 |
String name; |
634 |
if (endOfNameIndex != -1) {// is there a separator? |
647 |
String value; |
635 |
// case of name=value, name= |
648 |
int length = args[i].length(); |
636 |
metaData = ARG_VAL_SEP; |
649 |
int endOfNameIndex = args[i].indexOf(ARG_VAL_SEP); |
637 |
name = args[i].substring(0, endOfNameIndex); |
650 |
if (endOfNameIndex != -1) {// is there a separator? |
638 |
value = args[i].substring(endOfNameIndex + 1, length); |
651 |
// case of name=value, name= |
639 |
} else { |
652 |
metaData = ARG_VAL_SEP; |
640 |
metaData = ""; |
653 |
name = args[i].substring(0, endOfNameIndex); |
641 |
name=args[i]; |
654 |
value = args[i].substring(endOfNameIndex + 1, length); |
642 |
value=""; |
655 |
} else { |
643 |
} |
656 |
metaData = ""; |
644 |
if (name.length() > 0) { |
657 |
name=args[i]; |
645 |
// The browser has already done the encoding, so save the values as is |
658 |
value=""; |
646 |
HTTPArgument arg = new HTTPArgument(name, value, metaData, false); |
659 |
} |
647 |
// and make sure they stay that way: |
660 |
if (name.length() > 0) { |
648 |
arg.setAlwaysEncoded(false); |
661 |
// The browser has already done the encoding, so save the values as is |
649 |
// Note that URL.encode()/decode() do not follow RFC3986 entirely |
662 |
HTTPArgument arg = new HTTPArgument(name, value, metaData, false); |
650 |
this.getArguments().addArgument(arg); |
663 |
// and make sure they stay that way: |
651 |
// TODO: this leaves the arguments in encoded form, which may be difficult to read |
664 |
arg.setAlwaysEncoded(false); |
652 |
// if we can find proper coding methods, this could be tidied up |
665 |
// Note that URL.encode()/decode() do not follow RFC3986 entirely |
653 |
} |
666 |
this.getArguments().addArgument(arg); |
654 |
} |
667 |
// TODO: this leaves the arguments in encoded form, which may be difficult to read |
|
|
668 |
// if we can find proper coding methods, this could be tidied up |
669 |
} |
670 |
} |
671 |
} |
655 |
} |
672 |
} |
656 |
|
673 |
|
657 |
public String toString() { |
674 |
public String toString() { |
Lines 1009-1013
Link Here
|
1009 |
public static boolean isSecure(URL url){ |
1026 |
public static boolean isSecure(URL url){ |
1010 |
return isSecure(url.getProtocol()); |
1027 |
return isSecure(url.getProtocol()); |
1011 |
} |
1028 |
} |
|
|
1029 |
|
1030 |
/** |
1031 |
* check for xmlrpc request using xsd from http://www.ibiblio.org/xml/books/xmljava/chapters/ch02s05.html (no official xsd exists) |
1032 |
* |
1033 |
* @param queryString |
1034 |
* @return |
1035 |
*/ |
1036 |
private boolean isXmlRpc(String queryString) { |
1037 |
try { |
1038 |
if (!queryString.startsWith("<?xml")) |
1039 |
return false; |
1040 |
|
1041 |
if (xmlRpcParser == null) { |
1042 |
xmlRpcParser = new DOMParser(); |
1043 |
xmlRpcParser.setFeature("http://xml.org/sax/features/validation", true); |
1044 |
xmlRpcParser.setFeature("http://apache.org/xml/features/validation/schema", true); |
1045 |
xmlRpcParser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "xml-rpc.xsd"); |
1046 |
xmlRpcErrorHandler = new XmlRpcErrorHandler(); |
1047 |
xmlRpcParser.setErrorHandler(xmlRpcErrorHandler); |
1048 |
} |
1049 |
xmlRpcParser.parse(new InputSource(new ByteArrayInputStream(queryString.getBytes()))); |
1050 |
return xmlRpcErrorHandler.getParseErrors().length == 0; |
1051 |
} catch (Exception e) { |
1052 |
log.debug("isXmlRpc() " + e); |
1053 |
} |
1054 |
return false; |
1055 |
} |
1056 |
|
1012 |
} |
1057 |
} |
1013 |
|
1058 |
|