You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/02/04 20:55:52 UTC
svn commit: r618404 [1/4] - in /jakarta/jmeter/trunk: ./
src/protocol/http/org/apache/jmeter/protocol/http/control/
src/protocol/http/org/apache/jmeter/protocol/http/control/gui/
src/protocol/http/org/apache/jmeter/protocol/http/parser/ src/protocol/ht...
Author: sebb
Date: Mon Feb 4 11:55:48 2008
New Revision: 618404
URL: http://svn.apache.org/viewvc?rev=618404&view=rev
Log:
Add some missing svn:eol-style native properties
Modified:
jakarta/jmeter/trunk/LICENSE(htmlparser).txt (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java (contents, props changed)
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestFieldStringEditor.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jmeter/threads/TestTestCompiler.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java (contents, props changed)
jakarta/jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java (contents, props changed)
Modified: jakarta/jmeter/trunk/LICENSE(htmlparser).txt
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/LICENSE%28htmlparser%29.txt?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/LICENSE(htmlparser).txt (original)
+++ jakarta/jmeter/trunk/LICENSE(htmlparser).txt Mon Feb 4 11:55:48 2008
@@ -1,213 +1,213 @@
-Common Public License Version 1.0
-
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
-LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
-CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. DEFINITIONS
-
-"Contribution" means:
-
- a) in the case of the initial Contributor, the initial code and
-documentation distributed under this Agreement, and
-
- b) in the case of each subsequent Contributor:
-
- i) changes to the Program, and
-
- ii) additions to the Program;
-
- where such changes and/or additions to the Program originate from and are
-distributed by that particular Contributor. A Contribution 'originates' from a
-Contributor if it was added to the Program by such Contributor itself or anyone
-acting on such Contributor's behalf. Contributions do not include additions to
-the Program which: (i) are separate modules of software distributed in
-conjunction with the Program under their own license agreement, and (ii) are not
-derivative works of the Program.
-
-"Contributor" means any person or entity that distributes the Program.
-
-"Licensed Patents " mean patent claims licensable by a Contributor which are
-necessarily infringed by the use or sale of its Contribution alone or when
-combined with the Program.
-
-"Program" means the Contributions distributed in accordance with this Agreement.
-
-"Recipient" means anyone who receives the Program under this Agreement,
-including all Contributors.
-
-2. GRANT OF RIGHTS
-
- a) Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide, royalty-free copyright license to
-reproduce, prepare derivative works of, publicly display, publicly perform,
-distribute and sublicense the Contribution of such Contributor, if any, and such
-derivative works, in source code and object code form.
-
- b) Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
-Patents to make, use, sell, offer to sell, import and otherwise transfer the
-Contribution of such Contributor, if any, in source code and object code form.
-This patent license shall apply to the combination of the Contribution and the
-Program if, at the time the Contribution is added by the Contributor, such
-addition of the Contribution causes such combination to be covered by the
-Licensed Patents. The patent license shall not apply to any other combinations
-which include the Contribution. No hardware per se is licensed hereunder.
-
- c) Recipient understands that although each Contributor grants the licenses
-to its Contributions set forth herein, no assurances are provided by any
-Contributor that the Program does not infringe the patent or other intellectual
-property rights of any other entity. Each Contributor disclaims any liability to
-Recipient for claims brought by any other entity based on infringement of
-intellectual property rights or otherwise. As a condition to exercising the
-rights and licenses granted hereunder, each Recipient hereby assumes sole
-responsibility to secure any other intellectual property rights needed, if any.
-For example, if a third party patent license is required to allow Recipient to
-distribute the Program, it is Recipient's responsibility to acquire that license
-before distributing the Program.
-
- d) Each Contributor represents that to its knowledge it has sufficient
-copyright rights in its Contribution, if any, to grant the copyright license set
-forth in this Agreement.
-
-3. REQUIREMENTS
-
-A Contributor may choose to distribute the Program in object code form under its
-own license agreement, provided that:
-
- a) it complies with the terms and conditions of this Agreement; and
-
- b) its license agreement:
-
- i) effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title and
-non-infringement, and implied warranties or conditions of merchantability and
-fitness for a particular purpose;
-
- ii) effectively excludes on behalf of all Contributors all liability for
-damages, including direct, indirect, special, incidental and consequential
-damages, such as lost profits;
-
- iii) states that any provisions which differ from this Agreement are offered
-by that Contributor alone and not by any other party; and
-
- iv) states that source code for the Program is available from such
-Contributor, and informs licensees how to obtain it in a reasonable manner on or
-through a medium customarily used for software exchange.
-
-When the Program is made available in source code form:
-
- a) it must be made available under this Agreement; and
-
- b) a copy of this Agreement must be included with each copy of the Program.
-
-Contributors may not remove or alter any copyright notices contained within the
-Program.
-
-Each Contributor must identify itself as the originator of its Contribution, if
-any, in a manner that reasonably allows subsequent Recipients to identify the
-originator of the Contribution.
-
-4. COMMERCIAL DISTRIBUTION
-
-Commercial distributors of software may accept certain responsibilities with
-respect to end users, business partners and the like. While this license is
-intended to facilitate the commercial use of the Program, the Contributor who
-includes the Program in a commercial product offering should do so in a manner
-which does not create potential liability for other Contributors. Therefore, if
-a Contributor includes the Program in a commercial product offering, such
-Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
-every other Contributor ("Indemnified Contributor") against any losses, damages
-and costs (collectively "Losses") arising from claims, lawsuits and other legal
-actions brought by a third party against the Indemnified Contributor to the
-extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor to
-control, and cooperate with the Commercial Contributor in, the defense and any
-related settlement negotiations. The Indemnified Contributor may participate in
-any such claim at its own expense.
-
-For example, a Contributor might include the Program in a commercial product
-offering, Product X. That Contributor is then a Commercial Contributor. If that
-Commercial Contributor then makes performance claims, or offers warranties
-related to Product X, those performance claims and warranties are such
-Commercial Contributor's responsibility alone. Under this section, the
-Commercial Contributor would have to defend claims against the other
-Contributors related to those performance claims and warranties, and if a court
-requires any other Contributor to pay any damages as a result, the Commercial
-Contributor must pay those damages.
-
-5. NO WARRANTY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
-IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
-Recipient is solely responsible for determining the appropriateness of using and
-distributing the Program and assumes all risks associated with its exercise of
-rights under this Agreement, including but not limited to the risks and costs of
-program errors, compliance with applicable laws, damage to or loss of data,
-programs or equipment, and unavailability or interruption of operations.
-
-6. DISCLAIMER OF LIABILITY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
-CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
-PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
-GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. GENERAL
-
-If any provision of this Agreement is invalid or unenforceable under applicable
-law, it shall not affect the validity or enforceability of the remainder of the
-terms of this Agreement, and without further action by the parties hereto, such
-provision shall be reformed to the minimum extent necessary to make such
-provision valid and enforceable.
-
-If Recipient institutes patent litigation against a Contributor with respect to
-a patent applicable to software (including a cross-claim or counterclaim in a
-lawsuit), then any patent licenses granted by that Contributor to such Recipient
-under this Agreement shall terminate as of the date such litigation is filed. In
-addition, if Recipient institutes patent litigation against any entity
-(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
-itself (excluding combinations of the Program with other software or hardware)
-infringes such Recipient's patent(s), then such Recipient's rights granted under
-Section 2(b) shall terminate as of the date such litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails to
-comply with any of the material terms or conditions of this Agreement and does
-not cure such failure in a reasonable period of time after becoming aware of
-such noncompliance. If all Recipient's rights under this Agreement terminate,
-Recipient agrees to cease use and distribution of the Program as soon as
-reasonably practicable. However, Recipient's obligations under this Agreement
-and any licenses granted by Recipient relating to the Program shall continue and
-survive.
-
-Everyone is permitted to copy and distribute copies of this Agreement, but in
-order to avoid inconsistency the Agreement is copyrighted and may only be
-modified in the following manner. The Agreement Steward reserves the right to
-publish new versions (including revisions) of this Agreement from time to time.
-No one other than the Agreement Steward has the right to modify this Agreement.
-IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
-as the Agreement Steward to a suitable separate entity. Each new version of the
-Agreement will be given a distinguishing version number. The Program (including
-Contributions) may always be distributed subject to the version of the Agreement
-under which it was received. In addition, after a new version of the Agreement
-is published, Contributor may elect to distribute the Program (including its
-Contributions) under the new version. Except as expressly stated in Sections
-2(a) and 2(b) above, Recipient receives no rights or licenses to the
-intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.
-
-This Agreement is governed by the laws of the State of New York and the
-intellectual property laws of the United States of America. No party to this
-Agreement will bring a legal action under this Agreement more than one year
-after the cause of action arose. Each party waives its rights to a jury trial in
-any resulting litigation.
+Common Public License Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses
+to its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license set
+forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title and
+non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for
+damages, including direct, indirect, special, incidental and consequential
+damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered
+by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable manner on or
+through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the
+Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement, including but not limited to the risks and costs of
+program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to
+a patent applicable to software (including a cross-claim or counterclaim in a
+lawsuit), then any patent licenses granted by that Contributor to such Recipient
+under this Agreement shall terminate as of the date such litigation is filed. In
+addition, if Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
+itself (excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
+as the Agreement Steward to a suitable separate entity. Each new version of the
+Agreement will be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the Agreement
+is published, Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated in Sections
+2(a) and 2(b) above, Recipient receives no rights or licenses to the
+intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
Propchange: jakarta/jmeter/trunk/LICENSE(htmlparser).txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java Mon Feb 4 11:55:48 2008
@@ -1,106 +1,106 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.http.control;
-
-import org.apache.jmeter.testelement.AbstractTestElement;
-import org.apache.jmeter.testelement.property.IntegerProperty;
-import org.apache.jmeter.util.JMeterUtils;
-
-//For unit tests, @see TestHttpMirrorControl
-
-/**
- * Test element that implements the Workbench HTTP Mirror function
- */
-public class HttpMirrorControl extends AbstractTestElement {
-
- private transient HttpMirrorServer server;
-
- private static final int DEFAULT_PORT = 8080;
-
- // and as a string
- public static final String DEFAULT_PORT_S =
- Integer.toString(DEFAULT_PORT);// Used by GUI
-
- public static final String PORT = "HttpMirrorControlGui.port"; // $NON-NLS-1$
-
- public HttpMirrorControl() {
- initPort(DEFAULT_PORT);
- }
-
- public HttpMirrorControl(int port) {
- initPort(port);
- }
-
- private void initPort(int port){
- setProperty(new IntegerProperty(PORT, port));
- }
-
- public void setPort(int port) {
- initPort(port);
- }
-
- public void setPort(String port) {
- setProperty(PORT, port);
- }
-
- public String getClassLabel() {
- return JMeterUtils.getResString("httpmirror_title"); //$NON-NLS-1$
- }
-
-
- public int getPort() {
- return getPropertyAsInt(PORT);
- }
-
- public String getPortString() {
- return getPropertyAsString(PORT);
- }
-
- public int getDefaultPort() {
- return DEFAULT_PORT;
- }
-
- public Class getGuiClass() {
- return org.apache.jmeter.protocol.http.control.gui.HttpMirrorControlGui.class;
- }
-
- public void startHttpMirror() {
- server = new HttpMirrorServer(getPort());
- server.start();
- }
-
- public void stopHttpMirror() {
- if (server != null) {
- server.stopServer();
- try {
- server.join(1000); // wait for server to stop
- } catch (InterruptedException e) {
- }
- server = null;
- }
- }
-
- public boolean canRemove() {
- return null == server;
- }
-
- public boolean isServerAlive(){
- return server != null && server.isAlive();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.testelement.property.IntegerProperty;
+import org.apache.jmeter.util.JMeterUtils;
+
+//For unit tests, @see TestHttpMirrorControl
+
+/**
+ * Test element that implements the Workbench HTTP Mirror function
+ */
+public class HttpMirrorControl extends AbstractTestElement {
+
+ private transient HttpMirrorServer server;
+
+ private static final int DEFAULT_PORT = 8080;
+
+ // and as a string
+ public static final String DEFAULT_PORT_S =
+ Integer.toString(DEFAULT_PORT);// Used by GUI
+
+ public static final String PORT = "HttpMirrorControlGui.port"; // $NON-NLS-1$
+
+ public HttpMirrorControl() {
+ initPort(DEFAULT_PORT);
+ }
+
+ public HttpMirrorControl(int port) {
+ initPort(port);
+ }
+
+ private void initPort(int port){
+ setProperty(new IntegerProperty(PORT, port));
+ }
+
+ public void setPort(int port) {
+ initPort(port);
+ }
+
+ public void setPort(String port) {
+ setProperty(PORT, port);
+ }
+
+ public String getClassLabel() {
+ return JMeterUtils.getResString("httpmirror_title"); //$NON-NLS-1$
+ }
+
+
+ public int getPort() {
+ return getPropertyAsInt(PORT);
+ }
+
+ public String getPortString() {
+ return getPropertyAsString(PORT);
+ }
+
+ public int getDefaultPort() {
+ return DEFAULT_PORT;
+ }
+
+ public Class getGuiClass() {
+ return org.apache.jmeter.protocol.http.control.gui.HttpMirrorControlGui.class;
+ }
+
+ public void startHttpMirror() {
+ server = new HttpMirrorServer(getPort());
+ server.start();
+ }
+
+ public void stopHttpMirror() {
+ if (server != null) {
+ server.stopServer();
+ try {
+ server.join(1000); // wait for server to stop
+ } catch (InterruptedException e) {
+ }
+ server = null;
+ }
+ }
+
+ public boolean canRemove() {
+ return null == server;
+ }
+
+ public boolean isServerAlive(){
+ return server != null && server.isAlive();
+ }
+}
Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java Mon Feb 4 11:55:48 2008
@@ -1,115 +1,115 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.http.control;
-
-import java.io.InterruptedIOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
-
-/**
- * Server daemon thread.
- * Creates main socket and listens on it.
- * For each client request, creates a thread to handle the request.
- *
- */
-public class HttpMirrorServer extends Thread {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- /**
- * The time (in milliseconds) to wait when accepting a client connection.
- * The accept will be retried until the Daemon is told to stop. So this
- * interval is the longest time that the Daemon will have to wait after
- * being told to stop.
- */
- private static final int ACCEPT_TIMEOUT = 1000;
-
- /** The port to listen on. */
- private final int daemonPort;
-
- /** True if the Daemon is currently running. */
- private volatile boolean running;
-
- // Saves the error if one occurs
- private volatile Exception except;
-
- /**
- * Create a new Daemon with the specified port and target.
- *
- * @param port
- * the port to listen on.
- */
- public HttpMirrorServer(int port) {
- super("HttpMirrorServer");
- this.daemonPort = port;
- }
-
- /**
- * Listen on the daemon port and handle incoming requests. This method will
- * not exit until {@link #stopServer()} is called or an error occurs.
- */
- public void run() {
- except = null;
- running = true;
- ServerSocket mainSocket = null;
-
- try {
- log.info("Creating HttpMirror ... on port " + daemonPort);
- mainSocket = new ServerSocket(daemonPort);
- mainSocket.setSoTimeout(ACCEPT_TIMEOUT);
- log.info("HttpMirror up and running!");
-
- while (running) {
- try {
- // Listen on main socket
- Socket clientSocket = mainSocket.accept();
- if (running) {
- // Pass request to new thread
- HttpMirrorThread thd = new HttpMirrorThread(clientSocket);
- log.info("Starting new Mirror thread");
- thd.start();
- } else {
- log.warn("Server not running");
- JOrphanUtils.closeQuietly(clientSocket);
- }
- } catch (InterruptedIOException e) {
- // Timeout occurred. Ignore, and keep looping until we're
- // told to stop running.
- }
- }
- log.info("HttpMirror Server stopped");
- } catch (Exception e) {
- except = e;
- log.warn("HttpMirror Server stopped", e);
- } finally {
- JOrphanUtils.closeQuietly(mainSocket);
- }
- }
-
- public void stopServer() {
- running = false;
- }
-
- public Exception getException(){
- return except;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import java.io.InterruptedIOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
+import org.apache.log.Logger;
+
+/**
+ * Server daemon thread.
+ * Creates main socket and listens on it.
+ * For each client request, creates a thread to handle the request.
+ *
+ */
+public class HttpMirrorServer extends Thread {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ /**
+ * The time (in milliseconds) to wait when accepting a client connection.
+ * The accept will be retried until the Daemon is told to stop. So this
+ * interval is the longest time that the Daemon will have to wait after
+ * being told to stop.
+ */
+ private static final int ACCEPT_TIMEOUT = 1000;
+
+ /** The port to listen on. */
+ private final int daemonPort;
+
+ /** True if the Daemon is currently running. */
+ private volatile boolean running;
+
+ // Saves the error if one occurs
+ private volatile Exception except;
+
+ /**
+ * Create a new Daemon with the specified port and target.
+ *
+ * @param port
+ * the port to listen on.
+ */
+ public HttpMirrorServer(int port) {
+ super("HttpMirrorServer");
+ this.daemonPort = port;
+ }
+
+ /**
+ * Listen on the daemon port and handle incoming requests. This method will
+ * not exit until {@link #stopServer()} is called or an error occurs.
+ */
+ public void run() {
+ except = null;
+ running = true;
+ ServerSocket mainSocket = null;
+
+ try {
+ log.info("Creating HttpMirror ... on port " + daemonPort);
+ mainSocket = new ServerSocket(daemonPort);
+ mainSocket.setSoTimeout(ACCEPT_TIMEOUT);
+ log.info("HttpMirror up and running!");
+
+ while (running) {
+ try {
+ // Listen on main socket
+ Socket clientSocket = mainSocket.accept();
+ if (running) {
+ // Pass request to new thread
+ HttpMirrorThread thd = new HttpMirrorThread(clientSocket);
+ log.info("Starting new Mirror thread");
+ thd.start();
+ } else {
+ log.warn("Server not running");
+ JOrphanUtils.closeQuietly(clientSocket);
+ }
+ } catch (InterruptedIOException e) {
+ // Timeout occurred. Ignore, and keep looping until we're
+ // told to stop running.
+ }
+ }
+ log.info("HttpMirror Server stopped");
+ } catch (Exception e) {
+ except = e;
+ log.warn("HttpMirror Server stopped", e);
+ } finally {
+ JOrphanUtils.closeQuietly(mainSocket);
+ }
+ }
+
+ public void stopServer() {
+ running = false;
+ }
+
+ public Exception getException(){
+ return except;
+ }
+}
Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java Mon Feb 4 11:55:48 2008
@@ -1,181 +1,181 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.http.control;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.net.Socket;
-
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
-import org.apache.oro.text.regex.MatchResult;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternMatcherInput;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-
-/**
- * Thread to handle one client request. Gets the request from the client and
- * sends the response back to the client.
- */
-public class HttpMirrorThread extends Thread {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- private static final String ISO_8859_1 = "ISO-8859-1"; //$NON-NLS-1$
- private static final byte[] CRLF = { 0x0d, 0x0a };
-
- /** Socket to client. */
- private final Socket clientSocket;
-
- public HttpMirrorThread(Socket _clientSocket) {
- this.clientSocket=_clientSocket;
- }
-
- /**
- * Main processing method for the HttpMirror object
- */
- public void run() {
- log.info("Starting thread");
- BufferedInputStream in = null;
- BufferedOutputStream out = null;
-
- try {
- in = new BufferedInputStream(clientSocket.getInputStream());
- out = new BufferedOutputStream(clientSocket.getOutputStream());
- // The headers are written using ISO_8859_1 encoding
- out.write("HTTP/1.0 200 OK".getBytes(ISO_8859_1)); //$NON-NLS-1$
- out.write(CRLF);
- out.write("Content-Type: text/plain".getBytes(ISO_8859_1)); //$NON-NLS-1$
- out.write(CRLF);
- out.write(CRLF);
- out.flush();
-
- // Read the header part, we will be looking for a content-length
- // header, so we know how much we should read.
- // We assume headers are in ISO_8859_1
- // If we do not find such a header, we will just have to read until
- // we have to block to read more, until we support chunked transfer
- int contentLength = -1;
- boolean isChunked = false;
- byte[] buffer = new byte[1024];
- StringBuffer headers = new StringBuffer();
- int length = 0;
- int positionOfBody = 0;
- while(positionOfBody <= 0 && ((length = in.read(buffer)) != -1)) {
- out.write(buffer, 0, length); // echo back
- headers.append(new String(buffer, 0, length, ISO_8859_1));
- // Check if we have read all the headers
- positionOfBody = getPositionOfBody(headers.toString());
- }
-
- // Check if we have found a content-length header
- String contentLengthHeaderValue = getRequestHeaderValue(headers.toString(), "Content-Length"); //$NON-NLS-1$
- if(contentLengthHeaderValue != null) {
- contentLength = new Integer(contentLengthHeaderValue).intValue();
- }
- String transferEncodingHeaderValue = getRequestHeaderValue(headers.toString(), "Transfer-Encoding"); //$NON-NLS-1$
- if(transferEncodingHeaderValue != null) {
- isChunked = transferEncodingHeaderValue.equalsIgnoreCase("chunked"); //$NON-NLS-1$
- // We only support chunked transfer encoding
- if(!isChunked) {
- log.error("Transfer-Encoding header set, the value is not supported : " + transferEncodingHeaderValue);
- }
- }
-
- // If we know the content lenght, we can allow the reading of
- // the request to block until more data arrives.
- // If it is chunked transfer, we cannot allow the reading to
- // block, because we do not know when to stop reading, because
- // the chunked transfer is not properly supported yet
- length = 0;
- if(contentLength > 0) {
- // Check how much of the body we have already read as part of reading
- // the headers
- // We subtract two bytes for the crlf divider between header and body
- int totalReadBytes = headers.toString().length() - positionOfBody - 2;
-
- // We know when to stop reading, so we can allow the read method to block
- while((totalReadBytes < contentLength) && ((length = in.read(buffer)) != -1)) {
- out.write(buffer, 0, length);
-
- totalReadBytes += length;
- }
- }
- else if (isChunked) {
- // It is chunked transfer encoding, which we do not really support yet.
- // So we just read without blocking, because we do not know when to
- // stop reading, so we cannot block
- // TODO propery implement support for chunked transfer, i.e. to
- // know when we have read the whole request, and therefore allow
- // the reading to block
- while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
- out.write(buffer, 0, length);
- }
- }
- else {
- // The reqest has no body, or it has a transfer encoding we do not support.
- // In either case, we read any data available
- while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
- out.write(buffer, 0, length);
- }
- }
- out.flush();
- } catch (Exception e) {
- log.error("", e);
- } finally {
- JOrphanUtils.closeQuietly(out);
- JOrphanUtils.closeQuietly(in);
- JOrphanUtils.closeQuietly(clientSocket);
- }
- log.info("End of Thread");
- }
-
- private static String getRequestHeaderValue(String requestHeaders, String headerName) {
- Perl5Matcher localMatcher = JMeterUtils.getMatcher();
- // We use multi-line mask so can prefix the line with ^
- // also match \w+ to catch Transfer-Encoding: chunked
- // TODO: may need to be extended to allow for other header values with non-word contents
- String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$
- Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
- if(localMatcher.contains(requestHeaders, pattern)) {
- // The value is in the first group, group 0 is the whole match
- return localMatcher.getMatch().group(1);
- }
- else {
- return null;
- }
- }
-
- private static int getPositionOfBody(String stringToCheck) {
- Perl5Matcher localMatcher = JMeterUtils.getMatcher();
- // The headers and body are divided by a blank line (the \r is to allow for the CR before LF)
- String regularExpression = "^\\r$"; // $NON-NLS-1$
- Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
-
- PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
- if(localMatcher.contains(input, pattern)) {
- MatchResult match = localMatcher.getMatch();
- return match.beginOffset(0);
- }
- // No divider was found
- return -1;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.net.Socket;
+
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
+import org.apache.log.Logger;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+/**
+ * Thread to handle one client request. Gets the request from the client and
+ * sends the response back to the client.
+ */
+public class HttpMirrorThread extends Thread {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private static final String ISO_8859_1 = "ISO-8859-1"; //$NON-NLS-1$
+ private static final byte[] CRLF = { 0x0d, 0x0a };
+
+ /** Socket to client. */
+ private final Socket clientSocket;
+
+ public HttpMirrorThread(Socket _clientSocket) {
+ this.clientSocket=_clientSocket;
+ }
+
+ /**
+ * Main processing method for the HttpMirror object
+ */
+ public void run() {
+ log.info("Starting thread");
+ BufferedInputStream in = null;
+ BufferedOutputStream out = null;
+
+ try {
+ in = new BufferedInputStream(clientSocket.getInputStream());
+ out = new BufferedOutputStream(clientSocket.getOutputStream());
+ // The headers are written using ISO_8859_1 encoding
+ out.write("HTTP/1.0 200 OK".getBytes(ISO_8859_1)); //$NON-NLS-1$
+ out.write(CRLF);
+ out.write("Content-Type: text/plain".getBytes(ISO_8859_1)); //$NON-NLS-1$
+ out.write(CRLF);
+ out.write(CRLF);
+ out.flush();
+
+ // Read the header part, we will be looking for a content-length
+ // header, so we know how much we should read.
+ // We assume headers are in ISO_8859_1
+ // If we do not find such a header, we will just have to read until
+ // we have to block to read more, until we support chunked transfer
+ int contentLength = -1;
+ boolean isChunked = false;
+ byte[] buffer = new byte[1024];
+ StringBuffer headers = new StringBuffer();
+ int length = 0;
+ int positionOfBody = 0;
+ while(positionOfBody <= 0 && ((length = in.read(buffer)) != -1)) {
+ out.write(buffer, 0, length); // echo back
+ headers.append(new String(buffer, 0, length, ISO_8859_1));
+ // Check if we have read all the headers
+ positionOfBody = getPositionOfBody(headers.toString());
+ }
+
+ // Check if we have found a content-length header
+ String contentLengthHeaderValue = getRequestHeaderValue(headers.toString(), "Content-Length"); //$NON-NLS-1$
+ if(contentLengthHeaderValue != null) {
+ contentLength = new Integer(contentLengthHeaderValue).intValue();
+ }
+ String transferEncodingHeaderValue = getRequestHeaderValue(headers.toString(), "Transfer-Encoding"); //$NON-NLS-1$
+ if(transferEncodingHeaderValue != null) {
+ isChunked = transferEncodingHeaderValue.equalsIgnoreCase("chunked"); //$NON-NLS-1$
+ // We only support chunked transfer encoding
+ if(!isChunked) {
+ log.error("Transfer-Encoding header set, the value is not supported : " + transferEncodingHeaderValue);
+ }
+ }
+
+ // If we know the content lenght, we can allow the reading of
+ // the request to block until more data arrives.
+ // If it is chunked transfer, we cannot allow the reading to
+ // block, because we do not know when to stop reading, because
+ // the chunked transfer is not properly supported yet
+ length = 0;
+ if(contentLength > 0) {
+ // Check how much of the body we have already read as part of reading
+ // the headers
+ // We subtract two bytes for the crlf divider between header and body
+ int totalReadBytes = headers.toString().length() - positionOfBody - 2;
+
+ // We know when to stop reading, so we can allow the read method to block
+ while((totalReadBytes < contentLength) && ((length = in.read(buffer)) != -1)) {
+ out.write(buffer, 0, length);
+
+ totalReadBytes += length;
+ }
+ }
+ else if (isChunked) {
+ // It is chunked transfer encoding, which we do not really support yet.
+ // So we just read without blocking, because we do not know when to
+ // stop reading, so we cannot block
+ // TODO propery implement support for chunked transfer, i.e. to
+ // know when we have read the whole request, and therefore allow
+ // the reading to block
+ while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
+ out.write(buffer, 0, length);
+ }
+ }
+ else {
+ // The reqest has no body, or it has a transfer encoding we do not support.
+ // In either case, we read any data available
+ while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
+ out.write(buffer, 0, length);
+ }
+ }
+ out.flush();
+ } catch (Exception e) {
+ log.error("", e);
+ } finally {
+ JOrphanUtils.closeQuietly(out);
+ JOrphanUtils.closeQuietly(in);
+ JOrphanUtils.closeQuietly(clientSocket);
+ }
+ log.info("End of Thread");
+ }
+
+ private static String getRequestHeaderValue(String requestHeaders, String headerName) {
+ Perl5Matcher localMatcher = JMeterUtils.getMatcher();
+ // We use multi-line mask so can prefix the line with ^
+ // also match \w+ to catch Transfer-Encoding: chunked
+ // TODO: may need to be extended to allow for other header values with non-word contents
+ String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$
+ Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
+ if(localMatcher.contains(requestHeaders, pattern)) {
+ // The value is in the first group, group 0 is the whole match
+ return localMatcher.getMatch().group(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ private static int getPositionOfBody(String stringToCheck) {
+ Perl5Matcher localMatcher = JMeterUtils.getMatcher();
+ // The headers and body are divided by a blank line (the \r is to allow for the CR before LF)
+ String regularExpression = "^\\r$"; // $NON-NLS-1$
+ Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
+
+ PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
+ if(localMatcher.contains(input, pattern)) {
+ MatchResult match = localMatcher.getMatch();
+ return match.beginOffset(0);
+ }
+ // No divider was found
+ return -1;
+ }
+}
Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java Mon Feb 4 11:55:48 2008
@@ -1,171 +1,171 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.http.control.gui;
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.swing.Box;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import org.apache.jmeter.control.gui.LogicControllerGui;
-import org.apache.jmeter.gui.JMeterGUIComponent;
-import org.apache.jmeter.gui.UnsharedComponent;
-import org.apache.jmeter.gui.util.HorizontalPanel;
-import org.apache.jmeter.gui.util.MenuFactory;
-import org.apache.jmeter.protocol.http.control.HttpMirrorControl;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-public class HttpMirrorControlGui extends LogicControllerGui
- implements JMeterGUIComponent, ActionListener, UnsharedComponent {
- private static transient Logger log = LoggingManager.getLoggerForClass();
-
- private JTextField portField;
-
- private JButton stop, start;
-
- private static final String ACTION_STOP = "stop"; // $NON-NLS-1$
-
- private static final String ACTION_START = "start"; // $NON-NLS-1$
-
- private HttpMirrorControl mirrorController;
-
- public HttpMirrorControlGui() {
- super();
- log.debug("Creating HttpMirrorControlGui");
- init();
- }
-
- public TestElement createTestElement() {
- mirrorController = new HttpMirrorControl();
- log.debug("creating/configuring model = " + mirrorController);
- modifyTestElement(mirrorController);
- return mirrorController;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement el) {
- configureTestElement(el);
- if (el instanceof HttpMirrorControl) {
- mirrorController = (HttpMirrorControl) el;
- mirrorController.setPort(portField.getText());
- }
- }
-
- public String getLabelResource() {
- return "httpmirror_title"; // $NON-NLS-1$
- }
-
- public Collection getMenuCategories() {
- return Arrays.asList(new String[] { MenuFactory.NON_TEST_ELEMENTS });
- }
-
- public void configure(TestElement element) {
- log.debug("Configuring gui with " + element);
- super.configure(element);
- mirrorController = (HttpMirrorControl) element;
- portField.setText(mirrorController.getPortString());
- repaint();
- }
-
-
- public void actionPerformed(ActionEvent action) {
- String command = action.getActionCommand();
-
- if (command.equals(ACTION_STOP)) {
- mirrorController.stopHttpMirror();
- stop.setEnabled(false);
- start.setEnabled(true);
- } else if (command.equals(ACTION_START)) {
- modifyTestElement(mirrorController);
- mirrorController.startHttpMirror();
- start.setEnabled(false);
- stop.setEnabled(true);
- }
- }
-
- private void init() {
- setLayout(new BorderLayout(0, 5));
- setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
- JPanel mainPanel = new JPanel(new BorderLayout());
-
- Box myBox = Box.createVerticalBox();
- myBox.add(createPortPanel());
- mainPanel.add(myBox, BorderLayout.NORTH);
-
- mainPanel.add(createControls(), BorderLayout.CENTER);
-
- add(mainPanel, BorderLayout.CENTER);
- }
-
- private JPanel createControls() {
- start = new JButton(JMeterUtils.getResString("start")); // $NON-NLS-1$
- start.addActionListener(this);
- start.setActionCommand(ACTION_START);
- start.setEnabled(true);
-
- stop = new JButton(JMeterUtils.getResString("stop")); // $NON-NLS-1$
- stop.addActionListener(this);
- stop.setActionCommand(ACTION_STOP);
- stop.setEnabled(false);
-
- JPanel panel = new JPanel();
- panel.add(start);
- panel.add(stop);
- return panel;
- }
-
- private JPanel createPortPanel() {
- portField = new JTextField(HttpMirrorControl.DEFAULT_PORT_S, 8);
- portField.setName(HttpMirrorControl.PORT);
-
- JLabel label = new JLabel(JMeterUtils.getResString("port")); // $NON-NLS-1$
- label.setLabelFor(portField);
-
-
- HorizontalPanel panel = new HorizontalPanel();
- panel.add(label);
- panel.add(portField);
-
- panel.add(Box.createHorizontalStrut(10));
-
- return panel;
- }
-
- public void clearGui(){
- super.clearGui();
- portField.setText(HttpMirrorControl.DEFAULT_PORT_S);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control.gui;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.jmeter.control.gui.LogicControllerGui;
+import org.apache.jmeter.gui.JMeterGUIComponent;
+import org.apache.jmeter.gui.UnsharedComponent;
+import org.apache.jmeter.gui.util.HorizontalPanel;
+import org.apache.jmeter.gui.util.MenuFactory;
+import org.apache.jmeter.protocol.http.control.HttpMirrorControl;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class HttpMirrorControlGui extends LogicControllerGui
+ implements JMeterGUIComponent, ActionListener, UnsharedComponent {
+ private static transient Logger log = LoggingManager.getLoggerForClass();
+
+ private JTextField portField;
+
+ private JButton stop, start;
+
+ private static final String ACTION_STOP = "stop"; // $NON-NLS-1$
+
+ private static final String ACTION_START = "start"; // $NON-NLS-1$
+
+ private HttpMirrorControl mirrorController;
+
+ public HttpMirrorControlGui() {
+ super();
+ log.debug("Creating HttpMirrorControlGui");
+ init();
+ }
+
+ public TestElement createTestElement() {
+ mirrorController = new HttpMirrorControl();
+ log.debug("creating/configuring model = " + mirrorController);
+ modifyTestElement(mirrorController);
+ return mirrorController;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement el) {
+ configureTestElement(el);
+ if (el instanceof HttpMirrorControl) {
+ mirrorController = (HttpMirrorControl) el;
+ mirrorController.setPort(portField.getText());
+ }
+ }
+
+ public String getLabelResource() {
+ return "httpmirror_title"; // $NON-NLS-1$
+ }
+
+ public Collection getMenuCategories() {
+ return Arrays.asList(new String[] { MenuFactory.NON_TEST_ELEMENTS });
+ }
+
+ public void configure(TestElement element) {
+ log.debug("Configuring gui with " + element);
+ super.configure(element);
+ mirrorController = (HttpMirrorControl) element;
+ portField.setText(mirrorController.getPortString());
+ repaint();
+ }
+
+
+ public void actionPerformed(ActionEvent action) {
+ String command = action.getActionCommand();
+
+ if (command.equals(ACTION_STOP)) {
+ mirrorController.stopHttpMirror();
+ stop.setEnabled(false);
+ start.setEnabled(true);
+ } else if (command.equals(ACTION_START)) {
+ modifyTestElement(mirrorController);
+ mirrorController.startHttpMirror();
+ start.setEnabled(false);
+ stop.setEnabled(true);
+ }
+ }
+
+ private void init() {
+ setLayout(new BorderLayout(0, 5));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel(), BorderLayout.NORTH);
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ Box myBox = Box.createVerticalBox();
+ myBox.add(createPortPanel());
+ mainPanel.add(myBox, BorderLayout.NORTH);
+
+ mainPanel.add(createControls(), BorderLayout.CENTER);
+
+ add(mainPanel, BorderLayout.CENTER);
+ }
+
+ private JPanel createControls() {
+ start = new JButton(JMeterUtils.getResString("start")); // $NON-NLS-1$
+ start.addActionListener(this);
+ start.setActionCommand(ACTION_START);
+ start.setEnabled(true);
+
+ stop = new JButton(JMeterUtils.getResString("stop")); // $NON-NLS-1$
+ stop.addActionListener(this);
+ stop.setActionCommand(ACTION_STOP);
+ stop.setEnabled(false);
+
+ JPanel panel = new JPanel();
+ panel.add(start);
+ panel.add(stop);
+ return panel;
+ }
+
+ private JPanel createPortPanel() {
+ portField = new JTextField(HttpMirrorControl.DEFAULT_PORT_S, 8);
+ portField.setName(HttpMirrorControl.PORT);
+
+ JLabel label = new JLabel(JMeterUtils.getResString("port")); // $NON-NLS-1$
+ label.setLabelFor(portField);
+
+
+ HorizontalPanel panel = new HorizontalPanel();
+ panel.add(label);
+ panel.add(portField);
+
+ panel.add(Box.createHorizontalStrut(10));
+
+ return panel;
+ }
+
+ public void clearGui(){
+ super.clearGui();
+ portField.setText(HttpMirrorControl.DEFAULT_PORT_S);
+ }
}
Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpMirrorControlGui.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java Mon Feb 4 11:55:48 2008
@@ -1,195 +1,195 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.http.parser;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
-
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-import org.htmlparser.Node;
-import org.htmlparser.Parser;
-import org.htmlparser.Tag;
-import org.htmlparser.tags.AppletTag;
-import org.htmlparser.tags.BaseHrefTag;
-import org.htmlparser.tags.BodyTag;
-import org.htmlparser.tags.CompositeTag;
-import org.htmlparser.tags.FrameTag;
-import org.htmlparser.tags.ImageTag;
-import org.htmlparser.tags.InputTag;
-import org.htmlparser.tags.LinkTag;
-import org.htmlparser.tags.ScriptTag;
-import org.htmlparser.util.NodeIterator;
-import org.htmlparser.util.ParserException;
-
-/**
- * HtmlParser implementation using SourceForge's HtmlParser.
- *
- */
-class HtmlParserHTMLParser extends HTMLParser {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- static{
- org.htmlparser.scanners.ScriptScanner.STRICT = false; // Try to ensure that more javascript code is processed OK ...
- }
-
- protected HtmlParserHTMLParser() {
- super();
- log.info("Using htmlparser version: "+Parser.getVersion());
- }
-
- protected boolean isReusable() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.protocol.http.parser.HtmlParser#getEmbeddedResourceURLs(byte[],
- * java.net.URL)
- */
- public Iterator getEmbeddedResourceURLs(byte[] html, URL baseUrl, URLCollection urls) throws HTMLParseException {
-
- if (log.isDebugEnabled()) log.debug("Parsing html of: " + baseUrl);
-
- Parser htmlParser = null;
- try {
- String contents = new String(html);
- htmlParser = new Parser();
- htmlParser.setInputHTML(contents);
- } catch (Exception e) {
- throw new HTMLParseException(e);
- }
-
- // Now parse the DOM tree
- try {
- // we start to iterate through the elements
- parseNodes(htmlParser.elements(), new URLPointer(baseUrl), urls);
- log.debug("End : parseNodes");
- } catch (ParserException e) {
- throw new HTMLParseException(e);
- }
-
- return urls.iterator();
- }
-
- /*
- * A dummy class to pass the pointer of URL.
- */
- private static class URLPointer {
- private URLPointer(URL newUrl) {
- url = newUrl;
- }
- private URL url;
- }
-
- /**
- * Recursively parse all nodes to pick up all URL s.
- * @see e the nodes to be parsed
- * @see baseUrl Base URL from which the HTML code was obtained
- * @see urls URLCollection
- */
- private void parseNodes(final NodeIterator e,
- final URLPointer baseUrl, final URLCollection urls)
- throws HTMLParseException, ParserException {
- while(e.hasMoreNodes()) {
- Node node = e.nextNode();
- // a url is always in a Tag.
- if (!(node instanceof Tag)) {
- continue;
- }
- Tag tag = (Tag) node;
- String tagname=tag.getTagName();
- String binUrlStr = null;
-
- // first we check to see if body tag has a
- // background set
- if (tag instanceof BodyTag) {
- binUrlStr = tag.getAttribute(ATT_BACKGROUND);
- } else if (tag instanceof BaseHrefTag) {
- BaseHrefTag baseHref = (BaseHrefTag) tag;
- String baseref = baseHref.getBaseUrl().toString();
- try {
- if (!baseref.equals(""))// Bugzilla 30713
- {
- baseUrl.url = new URL(baseUrl.url, baseHref.getBaseUrl());
- }
- } catch (MalformedURLException e1) {
- throw new HTMLParseException(e1);
- }
- } else if (tag instanceof ImageTag) {
- ImageTag image = (ImageTag) tag;
- binUrlStr = image.getImageURL();
- } else if (tag instanceof AppletTag) {
- // look for applets
-
- // This will only work with an Applet .class file.
- // Ideally, this should be upgraded to work with Objects (IE)
- // and archives (.jar and .zip) files as well.
- AppletTag applet = (AppletTag) tag;
- binUrlStr = applet.getAppletClass();
- } else if (tag instanceof InputTag) {
- // we check the input tag type for image
- if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
- // then we need to download the binary
- binUrlStr = tag.getAttribute(ATT_SRC);
- }
- } else if (tag instanceof LinkTag) {
- LinkTag link = (LinkTag) tag;
- if (link.getChild(0) instanceof ImageTag) {
- ImageTag img = (ImageTag) link.getChild(0);
- binUrlStr = img.getImageURL();
- }
- } else if (tag instanceof ScriptTag) {
- binUrlStr = tag.getAttribute(ATT_SRC);
- } else if (tag instanceof FrameTag) {
- binUrlStr = tag.getAttribute(ATT_SRC);
- } else if (tagname.equalsIgnoreCase(TAG_EMBED)
- || tagname.equalsIgnoreCase(TAG_BGSOUND)){
- binUrlStr = tag.getAttribute(ATT_SRC);
- } else if (tagname.equalsIgnoreCase(TAG_LINK)) {
- // Putting the string first means it works even if the attribute is null
- if (STYLESHEET.equalsIgnoreCase(tag.getAttribute(ATT_REL))) {
- binUrlStr = tag.getAttribute(ATT_HREF);
- }
- } else {
- binUrlStr = tag.getAttribute(ATT_BACKGROUND);
- }
-
- if (binUrlStr != null) {
- urls.addURL(binUrlStr, baseUrl.url);
- }
-
- // Now look for URLs in the STYLE attribute
- String styleTagStr = tag.getAttribute(ATT_STYLE);
- if(styleTagStr != null) {
- HtmlParsingUtils.extractStyleURLs(baseUrl.url, urls, styleTagStr);
- }
-
- // second, if the tag was a composite tag,
- // recursively parse its children.
- if (tag instanceof CompositeTag) {
- CompositeTag composite = (CompositeTag) tag;
- parseNodes(composite.elements(), baseUrl, urls);
- }
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.parser;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.htmlparser.Node;
+import org.htmlparser.Parser;
+import org.htmlparser.Tag;
+import org.htmlparser.tags.AppletTag;
+import org.htmlparser.tags.BaseHrefTag;
+import org.htmlparser.tags.BodyTag;
+import org.htmlparser.tags.CompositeTag;
+import org.htmlparser.tags.FrameTag;
+import org.htmlparser.tags.ImageTag;
+import org.htmlparser.tags.InputTag;
+import org.htmlparser.tags.LinkTag;
+import org.htmlparser.tags.ScriptTag;
+import org.htmlparser.util.NodeIterator;
+import org.htmlparser.util.ParserException;
+
+/**
+ * HtmlParser implementation using SourceForge's HtmlParser.
+ *
+ */
+class HtmlParserHTMLParser extends HTMLParser {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ static{
+ org.htmlparser.scanners.ScriptScanner.STRICT = false; // Try to ensure that more javascript code is processed OK ...
+ }
+
+ protected HtmlParserHTMLParser() {
+ super();
+ log.info("Using htmlparser version: "+Parser.getVersion());
+ }
+
+ protected boolean isReusable() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.protocol.http.parser.HtmlParser#getEmbeddedResourceURLs(byte[],
+ * java.net.URL)
+ */
+ public Iterator getEmbeddedResourceURLs(byte[] html, URL baseUrl, URLCollection urls) throws HTMLParseException {
+
+ if (log.isDebugEnabled()) log.debug("Parsing html of: " + baseUrl);
+
+ Parser htmlParser = null;
+ try {
+ String contents = new String(html);
+ htmlParser = new Parser();
+ htmlParser.setInputHTML(contents);
+ } catch (Exception e) {
+ throw new HTMLParseException(e);
+ }
+
+ // Now parse the DOM tree
+ try {
+ // we start to iterate through the elements
+ parseNodes(htmlParser.elements(), new URLPointer(baseUrl), urls);
+ log.debug("End : parseNodes");
+ } catch (ParserException e) {
+ throw new HTMLParseException(e);
+ }
+
+ return urls.iterator();
+ }
+
+ /*
+ * A dummy class to pass the pointer of URL.
+ */
+ private static class URLPointer {
+ private URLPointer(URL newUrl) {
+ url = newUrl;
+ }
+ private URL url;
+ }
+
+ /**
+ * Recursively parse all nodes to pick up all URL s.
+ * @see e the nodes to be parsed
+ * @see baseUrl Base URL from which the HTML code was obtained
+ * @see urls URLCollection
+ */
+ private void parseNodes(final NodeIterator e,
+ final URLPointer baseUrl, final URLCollection urls)
+ throws HTMLParseException, ParserException {
+ while(e.hasMoreNodes()) {
+ Node node = e.nextNode();
+ // a url is always in a Tag.
+ if (!(node instanceof Tag)) {
+ continue;
+ }
+ Tag tag = (Tag) node;
+ String tagname=tag.getTagName();
+ String binUrlStr = null;
+
+ // first we check to see if body tag has a
+ // background set
+ if (tag instanceof BodyTag) {
+ binUrlStr = tag.getAttribute(ATT_BACKGROUND);
+ } else if (tag instanceof BaseHrefTag) {
+ BaseHrefTag baseHref = (BaseHrefTag) tag;
+ String baseref = baseHref.getBaseUrl().toString();
+ try {
+ if (!baseref.equals(""))// Bugzilla 30713
+ {
+ baseUrl.url = new URL(baseUrl.url, baseHref.getBaseUrl());
+ }
+ } catch (MalformedURLException e1) {
+ throw new HTMLParseException(e1);
+ }
+ } else if (tag instanceof ImageTag) {
+ ImageTag image = (ImageTag) tag;
+ binUrlStr = image.getImageURL();
+ } else if (tag instanceof AppletTag) {
+ // look for applets
+
+ // This will only work with an Applet .class file.
+ // Ideally, this should be upgraded to work with Objects (IE)
+ // and archives (.jar and .zip) files as well.
+ AppletTag applet = (AppletTag) tag;
+ binUrlStr = applet.getAppletClass();
+ } else if (tag instanceof InputTag) {
+ // we check the input tag type for image
+ if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
+ // then we need to download the binary
+ binUrlStr = tag.getAttribute(ATT_SRC);
+ }
+ } else if (tag instanceof LinkTag) {
+ LinkTag link = (LinkTag) tag;
+ if (link.getChild(0) instanceof ImageTag) {
+ ImageTag img = (ImageTag) link.getChild(0);
+ binUrlStr = img.getImageURL();
+ }
+ } else if (tag instanceof ScriptTag) {
+ binUrlStr = tag.getAttribute(ATT_SRC);
+ } else if (tag instanceof FrameTag) {
+ binUrlStr = tag.getAttribute(ATT_SRC);
+ } else if (tagname.equalsIgnoreCase(TAG_EMBED)
+ || tagname.equalsIgnoreCase(TAG_BGSOUND)){
+ binUrlStr = tag.getAttribute(ATT_SRC);
+ } else if (tagname.equalsIgnoreCase(TAG_LINK)) {
+ // Putting the string first means it works even if the attribute is null
+ if (STYLESHEET.equalsIgnoreCase(tag.getAttribute(ATT_REL))) {
+ binUrlStr = tag.getAttribute(ATT_HREF);
+ }
+ } else {
+ binUrlStr = tag.getAttribute(ATT_BACKGROUND);
+ }
+
+ if (binUrlStr != null) {
+ urls.addURL(binUrlStr, baseUrl.url);
+ }
+
+ // Now look for URLs in the STYLE attribute
+ String styleTagStr = tag.getAttribute(ATT_STYLE);
+ if(styleTagStr != null) {
+ HtmlParsingUtils.extractStyleURLs(baseUrl.url, urls, styleTagStr);
+ }
+
+ // second, if the tag was a composite tag,
+ // recursively parse its children.
+ if (tag instanceof CompositeTag) {
+ CompositeTag composite = (CompositeTag) tag;
+ parseNodes(composite.elements(), baseUrl, urls);
+ }
+ }
+ }
+
+}
Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParserHTMLParser.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org