diff --git a/.classpath b/.classpath
index a24bcf4b2..5f83c0be9 100644
--- a/.classpath
+++ b/.classpath
@@ -38,6 +38,10 @@
+
+
+
+
diff --git a/build.xml b/build.xml
index 24b5bdc1a..8ad7905eb 100644
--- a/build.xml
+++ b/build.xml
@@ -187,6 +187,10 @@
+
+
+
+
diff --git a/lib/apache-mime4j-0.6.License b/lib/apache-mime4j-0.6.License
new file mode 100644
index 000000000..2c41ec88f
--- /dev/null
+++ b/lib/apache-mime4j-0.6.License
@@ -0,0 +1,182 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) 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. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls.
+See http://www.jcip.net and the Creative Commons Attribution License
+(http://creativecommons.org/licenses/by/2.5)
+
diff --git a/lib/apache-mime4j-0.6.jar b/lib/apache-mime4j-0.6.jar
new file mode 100644
index 000000000..1d2282ce2
Binary files /dev/null and b/lib/apache-mime4j-0.6.jar differ
diff --git a/lib/httpclient-4.0.1.License b/lib/httpclient-4.0.1.License
new file mode 100644
index 000000000..2c41ec88f
--- /dev/null
+++ b/lib/httpclient-4.0.1.License
@@ -0,0 +1,182 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) 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. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls.
+See http://www.jcip.net and the Creative Commons Attribution License
+(http://creativecommons.org/licenses/by/2.5)
+
diff --git a/lib/httpclient-4.0.1.jar b/lib/httpclient-4.0.1.jar
new file mode 100644
index 000000000..e9c961f1b
Binary files /dev/null and b/lib/httpclient-4.0.1.jar differ
diff --git a/lib/httpcore-4.0.1.License b/lib/httpcore-4.0.1.License
new file mode 100644
index 000000000..2c41ec88f
--- /dev/null
+++ b/lib/httpcore-4.0.1.License
@@ -0,0 +1,182 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) 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. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls.
+See http://www.jcip.net and the Creative Commons Attribution License
+(http://creativecommons.org/licenses/by/2.5)
+
diff --git a/lib/httpcore-4.0.1.jar b/lib/httpcore-4.0.1.jar
new file mode 100644
index 000000000..4aef35e2f
Binary files /dev/null and b/lib/httpcore-4.0.1.jar differ
diff --git a/lib/httpmime-4.0.1.License b/lib/httpmime-4.0.1.License
new file mode 100644
index 000000000..2c41ec88f
--- /dev/null
+++ b/lib/httpmime-4.0.1.License
@@ -0,0 +1,182 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) 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. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls.
+See http://www.jcip.net and the Creative Commons Attribution License
+(http://creativecommons.org/licenses/by/2.5)
+
diff --git a/lib/httpmime-4.0.1.jar b/lib/httpmime-4.0.1.jar
new file mode 100644
index 000000000..c27df785b
Binary files /dev/null and b/lib/httpmime-4.0.1.jar differ
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index ebee4d65d..bb055e39b 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -1178,6 +1178,11 @@ public final class Switchboard extends serverSwitch {
tables.close();
UPnP.deletePortMapping();
Tray.removeTray();
+ try {
+ net.yacy.cora.protocol.Client.closeConnectionManager();
+ } catch (InterruptedException e) {
+ Log.logException(e);
+ }
log.logConfig("SWITCHBOARD SHUTDOWN TERMINATED");
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 84980591e..96a1e0ac8 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -51,6 +51,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -78,6 +79,8 @@ import net.yacy.repository.Blacklist;
import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.http.entity.mime.content.StringBody;
import de.anomic.crawler.ResultURLs;
import de.anomic.crawler.retrieval.EventOrigin;
@@ -141,14 +144,18 @@ public final class yacyClient {
Map result = null;
final String salt = crypt.randomSalt();
- final List post = yacyNetwork.basicRequestPost(Switchboard.getSwitchboard(), null, salt);
+// final List post = yacyNetwork.basicRequestPost(Switchboard.getSwitchboard(), null, salt);
try {
// generate request
- post.add(new DefaultCharsetStringPart("count", "20"));
- post.add(new DefaultCharsetStringPart("seed", mySeed.genSeedStr(salt)));
+ final LinkedHashMap parts = yacyNetwork.basicRequestParts(Switchboard.getSwitchboard(), null, salt);
+// post.add(new DefaultCharsetStringPart("count", "20"));
+ parts.put("count", new StringBody("20"));
+// post.add(new DefaultCharsetStringPart("seed", mySeed.genSeedStr(salt)));
+ parts.put("seed", new StringBody(mySeed.genSeedStr(salt)));
// send request
final long start = System.currentTimeMillis();
- final byte[] content = HttpConnector.wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post, 10000, false);
+// final byte[] content = HttpConnector.wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post, 10000, false);
+ final byte[] content = HttpConnector.wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", parts, 10000);
yacyCore.log.logInfo("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' contacted peer at " + address + ", received " + ((content == null) ? "null" : content.length) + " bytes, time = " + (System.currentTimeMillis() - start) + " milliseconds");
result = FileUtils.table(content);
} catch (final Exception e) {
@@ -1092,6 +1099,26 @@ public final class yacyClient {
} catch (final IOException e) {
Log.logException(e);
}
+ // new data
+ final LinkedHashMap newpost = new LinkedHashMap();
+ try {
+ newpost.put("process", new StringBody("permission"));
+ newpost.put("purpose", new StringBody("crcon"));
+ } catch (UnsupportedEncodingException e) {
+ Log.logException(e);
+ }
+ byte[] res;
+ try {
+ res = HttpConnector.wput(url.toString(), vhost, newpost, timeout);
+ System.out.println(new String(res));
+ } catch (IOException e1) {
+ Log.logException(e1);
+ }
+ try {
+ net.yacy.cora.protocol.Client.closeConnectionManager();
+ } catch (InterruptedException e) {
+ Log.logException(e);
+ }
}
}
diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.java
index 0a61438a3..bb1f63dc3 100644
--- a/source/de/anomic/yacy/yacyNetwork.java
+++ b/source/de/anomic/yacy/yacyNetwork.java
@@ -27,14 +27,18 @@
package de.anomic.yacy;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import net.yacy.kelondro.order.Digest;
import net.yacy.kelondro.util.DateFormatter;
import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.http.entity.mime.content.StringBody;
import de.anomic.http.client.DefaultCharsetStringPart;
import de.anomic.search.Switchboard;
@@ -105,4 +109,36 @@ public class yacyNetwork {
return post;
}
+ public static final LinkedHashMap basicRequestParts(final Switchboard sb, final String targetHash, final String salt) throws UnsupportedEncodingException {
+ // put in all the essentials for routing and network authentication
+ // generate a session key
+ final LinkedHashMap parts = new LinkedHashMap();
+ parts.put("key", new StringBody(salt));
+
+ // just standard identification essentials
+ parts.put("iam", new StringBody(sb.peers.mySeed().hash));
+ if (targetHash != null) parts.put("youare", new StringBody(targetHash));
+
+ // time information for synchronization
+ parts.put("mytime", new StringBody(DateFormatter.formatShortSecond(new Date())));
+ parts.put("myUTC", new StringBody(Long.toString(System.currentTimeMillis())));
+
+ // network identification
+ parts.put(SwitchboardConstants.NETWORK_NAME, new StringBody(Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, yacySeed.DFLT_NETWORK_UNIT)));
+
+ // authentication essentials
+ final String authenticationControl = sb.getConfig("network.unit.protocol.control", "uncontrolled");
+ final String authenticationMethod = sb.getConfig("network.unit.protocol.request.authentication.method", "");
+ if ((authenticationControl.equals("controlled")) && (authenticationMethod.length() > 0)) {
+ if (authenticationMethod.equals("salted-magic-sim")) {
+ // generate an authentication essential using the salt, the iam-hash and the network magic
+ final String magic = sb.getConfig("network.unit.protocol.request.authentication.essentials", "");
+ final String md5 = Digest.encodeMD5Hex(salt + sb.peers.mySeed().hash + magic);
+ parts.put("magicmd5", new StringBody(md5));
+ }
+ }
+
+ return parts;
+ }
+
}
diff --git a/source/net/yacy/cora/protocol/Client.java b/source/net/yacy/cora/protocol/Client.java
new file mode 100644
index 000000000..379fbe09b
--- /dev/null
+++ b/source/net/yacy/cora/protocol/Client.java
@@ -0,0 +1,347 @@
+package net.yacy.cora.protocol;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.params.ConnManagerParams;
+import org.apache.http.conn.params.ConnPerRouteBean;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+
+
+/**
+ *
+ * @author sixcooler
+ *
+ */
+public class Client {
+
+ private static IdledConnectionEvictor idledConnectionEvictor = null;
+ private static HttpClient httpClient = null;
+ private static int count = 0;
+ private int timeout = 10000;
+ private String userAgent = null;
+ private String host = null;
+
+ public Client() {
+ super();
+ if (httpClient == null) {
+ initConnectionManager();
+ }
+ }
+
+ private static void initConnectionManager() {
+ // Create and initialize HTTP parameters
+ HttpParams httpParams = new BasicHttpParams();
+ /**
+ * ConnectionManager settings
+ */
+ // TODO: how much connections do we need? - default: 20
+ // ConnManagerParams.setMaxTotalConnections(httpParams, 100);
+ // perhaps we need more than 2(default) connections per host?
+ ConnPerRouteBean connPerRoute = new ConnPerRouteBean(2);
+ // Increase max connections for localhost to 100
+ HttpHost localhost = new HttpHost("locahost");
+ connPerRoute.setMaxForRoute(new HttpRoute(localhost), 100);
+ ConnManagerParams.setMaxConnectionsPerRoute(httpParams, connPerRoute);
+ // how long to wait for getting a connection from manager in milliseconds
+ ConnManagerParams.setTimeout(httpParams, 3000L);
+ /**
+ * HTTP protocol settings
+ */
+ HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
+ // UserAgent
+ HttpProtocolParams.setUserAgent(httpParams, "yacy (" + systemOST +") yacy.net");
+ /**
+ * HTTP connection settings
+ */
+ // timeout in milliseconds until a connection is established in milliseconds
+ HttpConnectionParams.setConnectionTimeout(httpParams, 10000);
+ // SO_LINGER affects the socket close operation in seconds
+ HttpConnectionParams.setLinger(httpParams, 6);
+ // TODO: is default ok?
+ // HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
+ // SO_TIMEOUT: maximum period inactivity between two consecutive data packets in milliseconds
+ HttpConnectionParams.setSoTimeout(httpParams, 5000);
+ // getting an I/O error when executing a request over a connection that has been closed at the server side
+ HttpConnectionParams.setStaleCheckingEnabled(httpParams, true);
+ // conserve bandwidth by minimizing the number of segments that are sent
+ HttpConnectionParams.setTcpNoDelay(httpParams, false);
+
+ // Create and initialize scheme registry
+ SchemeRegistry schemeRegistry = new SchemeRegistry();
+ schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
+
+ ClientConnectionManager clientConnectionManager = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
+
+ httpClient = new DefaultHttpClient(clientConnectionManager, httpParams);
+
+ idledConnectionEvictor = new IdledConnectionEvictor(clientConnectionManager);
+ idledConnectionEvictor.start();
+
+ }
+
+ /**
+ * this should be called just before shutdown
+ * @throws InterruptedException
+ */
+ public static void closeConnectionManager() throws InterruptedException {
+ if (idledConnectionEvictor != null) {
+ // Shut down the evictor thread
+ idledConnectionEvictor.shutdown();
+ idledConnectionEvictor.join();
+ }
+ if (httpClient != null) {
+ // Shut down the connection manager
+ httpClient.getConnectionManager().shutdown();
+ }
+
+ }
+
+ /**
+ *
+ * @param timeout in milliseconds
+ */
+ public void setTimout(final int timeout) {
+ this.timeout = timeout;
+ }
+
+ /**
+ * @param userAgent
+ */
+ public void setUserAgent(final String userAgent) {
+ this.userAgent = userAgent;
+ }
+
+ /**
+ * @param host
+ */
+ public void setHost(final String host) {
+ this.host = host;
+ }
+
+ /**
+ * number of active connections
+ *
+ * @return number of active connections
+ */
+ public static int connectionCount() {
+ return count;
+ }
+
+ /**
+ * This method GETs a page from the server.
+ *
+ * @param uri the url to get
+ * @return content bytes
+ * @throws IOException
+ */
+ public byte[] GETbytes(final String uri) throws IOException {
+ return GETbytes(uri, Long.MAX_VALUE);
+ }
+
+ /**
+ * This method GETs a page from the server.
+ *
+ * @param uri the url to get
+ * @param maxBytes to get
+ * @return content bytes
+ * @throws IOException
+ */
+ public byte[] GETbytes(final String uri, long maxBytes) throws IOException {
+ HttpGet httpGet = new HttpGet(uri);
+ return getContentBytes(httpGet, maxBytes);
+ }
+
+ /**
+ *
+ * @param uri the url to post
+ * @param parts to post
+ * @return content bytes
+ * @throws IOException
+ */
+ public byte[] POSTbytes(final String uri, LinkedHashMap parts) throws IOException {
+ HttpPost httpPost = new HttpPost(uri);
+
+ MultipartEntity multipartEntity = new MultipartEntity();
+ for (Entry part : parts.entrySet())
+ multipartEntity.addPart(part.getKey(), part.getValue());
+
+ httpPost.setEntity(multipartEntity);
+
+ return getContentBytes(httpPost, Long.MAX_VALUE);
+ }
+
+ private byte[] getContentBytes(HttpUriRequest httpUriRequest, long maxBytes) throws IOException {
+ count++;
+ byte[] content = null;
+ final HttpContext httpContext = new BasicHttpContext();
+ httpUriRequest.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
+ if (userAgent != null)
+ httpUriRequest.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
+ if (host != null)
+ httpUriRequest.getParams().setParameter(HTTP.TARGET_HOST, host);
+
+ try {
+ // execute the method
+ HttpResponse httpResponse = httpClient.execute(httpUriRequest, httpContext);
+ // get the response body
+ HttpEntity httpEntity = httpResponse.getEntity();
+ if (httpEntity != null) {
+ if (httpEntity.getContentLength() < maxBytes) {
+ content = EntityUtils.toByteArray(httpEntity);
+ }
+ // TODO: The name of this method is misnomer.
+ // It will be renamed to #finish() in the next major release of httpcore
+ httpEntity.consumeContent();
+ }
+ } catch (final IOException e) {
+ httpUriRequest.abort();
+ throw e;
+ }
+ count--;
+ return content;
+ }
+
+ /**
+ * provide system information for client identification
+ */
+ private static final String systemOST = System.getProperty("os.arch", "no-os-arch") + " " +
+ System.getProperty("os.name", "no-os-name") + " " + System.getProperty("os.version", "no-os-version") +
+ "; " + "java " + System.getProperty("java.version", "no-java-version") + "; " + generateLocation();
+
+ /**
+ * generating the location string
+ *
+ * @return
+ */
+ public static String generateLocation() {
+ String loc = System.getProperty("user.timezone", "nowhere");
+ final int p = loc.indexOf('/');
+ if (p > 0) {
+ loc = loc.substring(0, p);
+ }
+ loc = loc + "/" + System.getProperty("user.language", "dumb");
+ return loc;
+ }
+
+ /**
+ * testing
+ *
+ * @param args urls to test
+ */
+ public static void main(final String[] args) {
+ String url = null;
+ // prepare Parts
+ final LinkedHashMap newparts = new LinkedHashMap();
+ try {
+ newparts.put("foo", new StringBody("FooBar"));
+ newparts.put("bar", new StringBody("BarFoo"));
+ } catch (UnsupportedEncodingException e) {
+ System.out.println(e.getStackTrace());
+ }
+ Client client = new Client();
+ client.setUserAgent("foobar");
+ client.setHost("sixcooler");
+ // Get some
+ for (int i = 0; i < args.length; i++) {
+ url = args[i];
+ if (!url.toUpperCase().startsWith("HTTP://")) {
+ url = "http://" + url;
+ }
+ try {
+ System.out.println(new String(client.GETbytes(url)));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ // Post some
+ try {
+ System.out.println(new String(client.POSTbytes(url, newparts)));
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ try {
+ Client.closeConnectionManager();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ *
+ * @see: http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e638
+ *
+ */
+ public static class IdledConnectionEvictor extends Thread {
+
+ private final ClientConnectionManager clientConnectionManager;
+
+ private volatile boolean shutdown;
+
+ public IdledConnectionEvictor(ClientConnectionManager clientConnectionManager) {
+ super();
+ this.clientConnectionManager = clientConnectionManager;
+ }
+
+ @Override
+ public void run() {
+ try {
+ while (!shutdown) {
+ synchronized (this) {
+ wait(5000);
+ // Close expired connections
+ clientConnectionManager.closeExpiredConnections();
+ // Optionally, close connections
+ // that have been idle longer than 5 sec
+ // (some SOHO router act strange on >5sec idled connections)
+ clientConnectionManager.closeIdleConnections(5, TimeUnit.SECONDS);
+ }
+ }
+ } catch (InterruptedException ex) {
+ // terminate
+ }
+ }
+
+ public void shutdown() {
+ shutdown = true;
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+
+ }
+
+}
diff --git a/source/net/yacy/cora/protocol/HttpConnector.java b/source/net/yacy/cora/protocol/HttpConnector.java
index d126c9f3d..1a32bf5f8 100644
--- a/source/net/yacy/cora/protocol/HttpConnector.java
+++ b/source/net/yacy/cora/protocol/HttpConnector.java
@@ -22,14 +22,16 @@
package net.yacy.cora.protocol;
import java.io.IOException;
+import java.util.LinkedHashMap;
import java.util.List;
import net.yacy.cora.document.MultiProtocolURI;
import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.http.entity.mime.content.ContentBody;
import de.anomic.crawler.retrieval.HTTPLoader;
-import de.anomic.http.client.Client;
+// import de.anomic.http.client.Client;
import de.anomic.http.server.HeaderFramework;
import de.anomic.http.server.RequestHeader;
import de.anomic.http.server.ResponseContainer;
@@ -65,7 +67,7 @@ public class HttpConnector {
final RequestHeader header = new RequestHeader();
header.put(HeaderFramework.USER_AGENT, HTTPLoader.yacyUserAgent);
header.put(HeaderFramework.HOST, vhost);
- final Client client = new Client(timeout, header);
+ final de.anomic.http.client.Client client = new de.anomic.http.client.Client(timeout, header);
ResponseContainer res = null;
byte[] content = null;
@@ -82,29 +84,48 @@ public class HttpConnector {
return content;
}
+ public static byte[] wput(final String url, final String vhost, LinkedHashMap post, final int timeout) throws IOException {
+ final Client client = new Client();
+ client.setTimout(timeout);
+ client.setUserAgent(HTTPLoader.yacyUserAgent);
+ client.setHost(vhost);
+
+ return client.POSTbytes(url, post);
+ }
+
+ public static byte[] wget(final String url, final String vhost, final int timeout) throws IOException {
+ final Client client = new Client();
+ client.setTimout(timeout);
+ client.setUserAgent(HTTPLoader.yacyUserAgent);
+ client.setHost(vhost);
+
+ return client.GETbytes(url);
+ }
+
+
public static byte[] wget(final MultiProtocolURI url, final int timeout) throws IOException {
return wget(url.toNormalform(false, false), url.getHost(), timeout);
}
- public static byte[] wget(final String url, final String vhost, final int timeout) throws IOException {
- final RequestHeader header = new RequestHeader();
- header.put(HeaderFramework.USER_AGENT, HTTPLoader.yacyUserAgent);
- header.put(HeaderFramework.HOST, vhost);
- final Client client = new Client(timeout, header);
-
- ResponseContainer res = null;
- byte[] content = null;
- try {
- // send request/data
- res = client.GET(url);
- content = res.getData();
- } finally {
- if(res != null) {
- // release connection
- res.closeStream();
- }
- }
- return content;
- }
+// public static byte[] wget(final String url, final String vhost, final int timeout) throws IOException {
+// final RequestHeader header = new RequestHeader();
+// header.put(HeaderFramework.USER_AGENT, HTTPLoader.yacyUserAgent);
+// header.put(HeaderFramework.HOST, vhost);
+// final de.anomic.http.client.Client client = new de.anomic.http.client.Client(timeout, header);
+//
+// ResponseContainer res = null;
+// byte[] content = null;
+// try {
+// // send request/data
+// res = client.GET(url);
+// content = res.getData();
+// } finally {
+// if(res != null) {
+// // release connection
+// res.closeStream();
+// }
+// }
+// return content;
+// }
}