Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/net/http
In directory sc8-pr-cvs1:/tmp/cvs-serv16302/src/java/core/org/krysalis/ruper2/util/net/http
Modified Files:
HttpClientUserAgent.java
Log Message:
Attempt to bring closer to working w/ Anou's API.
Index: HttpClientUserAgent.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/net/http/HttpClientUserAgent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HttpClientUserAgent.java 9 Oct 2003 21:14:58 -0000 1.2
--- HttpClientUserAgent.java 10 Oct 2003 21:26:25 -0000 1.3
***************
*** 14,17 ****
--- 14,18 ----
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.util.HttpURLConnection;
+ import org.krysalis.ruper2.log.Logger;
import org.krysalis.ruper2.util.io.IOUtils;
import org.krysalis.ruper2.version.Version;
***************
*** 21,24 ****
--- 22,26 ----
* @author arb_jack
*
+ * A simple UserAgent
*
*/
***************
*** 27,35 ****
public HttpClientUserAgent() {
- initClass();
- }
-
- private void initClass() {
m_client = new HttpClient();
//
--- 29,34 ----
public HttpClientUserAgent() {
m_client = new HttpClient();
+ //new MultiThreadedHttpConnectionManager());
//
***************
*** 39,48 ****
}
public boolean exists(String url) {
boolean exists = false;
! HeadMethod head = getHead(url);
try {
int resultCode = m_client.executeMethod(head);
--- 38,57 ----
}
+ /**
+ * Test if a URL 'exists' by performing an HTTP HEAD and
+ * testing the status code response.
+ *
+ * @param url
+ * @return
+ */
public boolean exists(String url) {
boolean exists = false;
! HeadMethod head = null;
try {
+
+ head = getHead(url);
+
int resultCode = m_client.executeMethod(head);
***************
*** 50,54 ****
}
catch (Exception ex) {
! ex.printStackTrace();
}
finally {
--- 59,63 ----
}
catch (Exception ex) {
! Logger.getLog().error("Failed to HTTP HEAD [" + url + "]", ex);
}
finally {
***************
*** 59,68 ****
}
public String getContents(String url) {
String content = null;
! GetMethod get = getGet(url);
try {
int resultCode = m_client.executeMethod(get);
--- 68,84 ----
}
+ /**
+ * Return the contents of a GET to a URL as a String
+ * @param url
+ * @return
+ */
public String getContents(String url) {
String content = null;
! GetMethod get = null;
try {
+ get = getGet(url);
+
int resultCode = m_client.executeMethod(get);
***************
*** 71,75 ****
}
catch (Exception ex) {
! ex.printStackTrace();
}
finally {
--- 87,91 ----
}
catch (Exception ex) {
! Logger.getLog().error("Failed to HTTP GET [" + url + "]", ex);
}
finally {
***************
*** 80,87 ****
}
public void transferContents(String url, OutputStream output) {
! GetMethod get = getGet(url);
try {
int resultCode = m_client.executeMethod(get);
--- 96,110 ----
}
+ /**
+ * Copy the contents of a GET of a URL to another stream
+ * @param url
+ * @param output
+ */
public void transferContents(String url, OutputStream output) {
! GetMethod get = null;
try {
+ get = getGet(url);
+
int resultCode = m_client.executeMethod(get);
***************
*** 94,98 ****
}
catch (Exception ex) {
! ex.printStackTrace();
}
finally {
--- 117,121 ----
}
catch (Exception ex) {
! Logger.getLog().error("Failed to HTTP GET [" + url + "]", ex);
}
finally {
***************
*** 102,105 ****
--- 125,133 ----
}
+ /**
+ * Return a configured HEAD method to a URL
+ * @param url
+ * @return
+ */
private GetMethod getGet(String url) {
GetMethod get = new GetMethod(url);
***************
*** 108,111 ****
--- 136,144 ----
}
+ /**
+ * Return a configured HEAD method to a URL
+ * @param url
+ * @return
+ */
private HeadMethod getHead(String url) {
HeadMethod head = new HeadMethod(url);
***************
*** 115,122 ****
/**
! * Prepares a Method object.
*/
! private void configureMethod(final HttpMethod method) {
! //method.setPath( );
method.setFollowRedirects(true);
method.setRequestHeader(
--- 148,156 ----
/**
! *
! * Prepares a method with out standard preferences.
! *
*/
! private void configureMethod(HttpMethod method) {
method.setFollowRedirects(true);
method.setRequestHeader(
***************
*** 129,132 ****
--- 163,168 ----
String url = "http://www.ibiblio.org/maven/junit/jars";
+ if (args.length > 0)
+ url = args[0];
PrintWriter out = SystemUtils.getSystemOut();
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.