hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Dever <jsde...@sympatico.ca>
Subject Re: [PATCH] Samples cleaned up
Date Tue, 17 Dec 2002 01:37:39 GMT
Committed.

Ortwin Glück wrote:

> I tried an cleaned up the samples a bit.
>
> - reformatted
> - got rid of deprecated methods, used HostConfiguration
> - fixed some bugs
>
> I added some convenience to some classes:
>
> - URI can be constructed from URL now
> - HostConfiguration.setHost(URI) sets protocol, host, port from URI
>
> As posted earlier in this list I agree that constructing the 
> HttpClient (HostConfig) is now over-complicated. We could have the 
> possibility to pass a URL/URI in one single place: either Method or 
> Client.
>
> Comments?
>
> Odi
>
>
>------------------------------------------------------------------------
>
>? patch.diff
>Index: ClientApp.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/ClientApp.java,v
>retrieving revision 1.7
>diff -u -w -r1.7 ClientApp.java
>--- ClientApp.java	8 Sep 2002 05:19:06 -0000	1.7
>+++ ClientApp.java	16 Dec 2002 17:13:17 -0000
>@@ -1,5 +1,5 @@
> /*
>- * $Header $
>+ * $Header: $
>  * $Revision: 1.2 $
>  * $Date: 2002/08/08 01:24:30 $
>  * 
>@@ -78,13 +78,11 @@
>  * how to use the Jakarta HttpClient API.
>  * 
>  * @author Sean C. Sullivan
>- *
>+ * @author Ortwin Glück
>  */
>-public class ClientApp
>-{
>+public class ClientApp {
> 
>-	public static void main(String[] args)
>-	{
>+    public static void main(String[] args) {
> 		HttpClientMainFrame f = new HttpClientMainFrame();
> 		f.setTitle("HttpClient demo application");
> 		f.setSize(700, 500);
>@@ -92,41 +90,37 @@
> 		f.setVisible(true);
> 	}
> 
>-	public static class HttpClientMainFrame extends javax.swing.JFrame
>-	{
>+    public static class HttpClientMainFrame extends javax.swing.JFrame {
> 		private HttpClientPanel m_panel;
> 
>-		public HttpClientMainFrame()
>-		{
>+        public HttpClientMainFrame() {
> 			m_panel = new HttpClientPanel();
> 			this.getContentPane().add(m_panel);
> 		}
> 	}
> 
>-	public static class HttpClientPanel extends JPanel
>-	{
>+    public static class HttpClientPanel extends JPanel {
> 		private static final String strTenSpaces = "          ";
> 		private static final String strFortySpaces =
> 			strTenSpaces + strTenSpaces + strTenSpaces + strTenSpaces;
> 		private static final String strEightySpaces =
> 			strFortySpaces + strFortySpaces;
> 
>-		public HttpClientPanel()
>-		{
>+        public HttpClientPanel() {
> 			final JPanel panInput = new JPanel();
> 			panInput.setLayout(new FlowLayout());
> 
> 			final JPanel panDisplay = new JPanel();
> 			panDisplay.setLayout(new BorderLayout());
> 
>-			String[] aURLs =
>-				{
>+            String[] aURLs = {
> 					"http://www.apache.org/",
> 					"http://www.google.com/",
> 					"http://www.opensource.org/",
> 					"http://www.anybrowser.org/",
> 					"http://jakarta.apache.org/",
>-					"http://www.w3.org/" };
>+                    "http://www.w3.org/"
>+            };
> 
> 			final JComboBox cmbURL = new JComboBox(aURLs);
> 			cmbURL.setToolTipText("Enter a URL");
>@@ -142,54 +136,53 @@
> 
> 			final JButton btnGET = new JButton("GET");
> 
>-			cmbURL.addActionListener(new ActionListener()
>-			{
>+            cmbURL.addActionListener(new ActionListener() {
> 				public void actionPerformed(ActionEvent ae)
> 				{
> 					btnGET.doClick();
> 				}
> 			});
> 
>-			btnGET.addActionListener(new ActionListener()
>-			{
>-				public void actionPerformed(ActionEvent ae)
>-				{
>+            btnGET.addActionListener(new ActionListener() {
>+                public void actionPerformed(ActionEvent ae) {
> 					final String strRawURL = (String) cmbURL.getSelectedItem();
>-					if (strRawURL.length() > 0)
>-					{
>+                    if (strRawURL.length() > 0) {
> 						final URL u;
>-						try
>-						{
>+                        try {
> 							u = new URL(strRawURL.trim());
>-							Thread t = new Thread()
>-							{
>-								public void run()
>-								{
>-									HttpClient client = new HttpClient();
>+                            Thread t = new Thread() {
>+                                public void run() {
>+                                    HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
> 									GetMethod get = new GetMethod();
> 									HeadMethod head = new HeadMethod();
>-									client.startSession(u);
>-									client.setTimeout(30000 /* milliseconds */
>-									);
>+                                    HostConfiguration hc = new HostConfiguration();
>+                                    try {
>+                                        hc.setHost(new URI(u));
>+                                    } catch(URIException e) {
>+                                        throw new RuntimeException(e.toString());
>+                                    }
>+                                    client.setHostConfiguration(hc);
>+                                    client.setConnectionTimeout(30000);
> 									int iGetResultCode;
> 									int iHeadResultCode;
>-									try
>-									{
>+                                    try {
>+                                        //to execute two methods in a row without reading
the first method's response
>+                                        //we *need* the MultiThreadedHttpConnectionManager
as set in the HttpClient's
>+                                        //constructor.
> 										iGetResultCode = client.executeMethod(get);
> 										iHeadResultCode = client.executeMethod(head);
> 										
> 										final String strGetResponseBody =
> 											get.getResponseBodyAsString();
>+                                        get.releaseConnection();
> 											
> 										final String strHeadResponseBody =
> 											head.getResponseBodyAsString();
>+                                        head.releaseConnection();
> 											
>-										if (strGetResponseBody != null)
>-										{
>-											Runnable r = new Runnable()
>-											{
>-												public void run()
>-												{
>+                                        if (strGetResponseBody != null) {
>+                                            Runnable r = new Runnable() {
>+                                                public void run() {
> 													panDisplay.removeAll();
> 		
> 													taTextResponse.setText(
>@@ -197,11 +190,9 @@
> 													taTextResponse.setCaretPosition(0);
> 													taTextResponse.requestFocus();
> 		
>-													try
>-													{
> 														JEditorPane htmlPane =
>-															new JEditorPane(
>-																u.toExternalForm());
>+                                                        new JEditorPane("text/html",
>+                                                            strGetResponseBody);
> 														htmlPane.setEditable(false);
> 			
> 														final JSplitPane splitResponsePane =
>@@ -222,40 +213,25 @@
> 			
> 														panDisplay.validate();
> 													}
>-													catch (java.io.IOException ex)
>-													{
>-														ex.printStackTrace();
>-													}
>-												}
> 											};
>-											try
>-											{
>+                                            try {
> 												SwingUtilities.invokeAndWait(r);
>-											}
>-											catch (InvocationTargetException ex)
>-											{
>+                                            } catch (InvocationTargetException ex) {
> 												ex.printStackTrace();
>-											}
>-											catch (InterruptedException ex)
>-											{
>+                                            } catch (InterruptedException ex) {
> 												ex.printStackTrace();
> 											}
> 										}
> 									}
>-									catch (HttpException ex)
>-									{
>+                                    catch (HttpException ex) {
> 										ex.printStackTrace();
>-									}
>-									catch (IOException ex)
>-									{
>+                                    } catch (IOException ex) {
> 										ex.printStackTrace();
> 									}
> 								}
> 							};
> 							t.start();
>-						}
>-						catch (MalformedURLException ignored)
>-						{
>+                        } catch (MalformedURLException ignored) {
> 							// ignore
> 						}
> 					}
>Index: CookieDemoApp.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/CookieDemoApp.java,v
>retrieving revision 1.4
>diff -u -w -r1.4 CookieDemoApp.java
>--- CookieDemoApp.java	29 Sep 2002 15:23:28 -0000	1.4
>+++ CookieDemoApp.java	16 Dec 2002 17:13:17 -0000
>@@ -78,8 +78,7 @@
>  * @author Sean C. Sullivan
>  *
>  */
>-public class CookieDemoApp
>-{
>+public class CookieDemoApp {
> 	private static final String COOKIE_NAME = "count";
> 
>     /**
>@@ -92,11 +91,10 @@
>      *                
>      * 
>      */
>-	public static void main(String[] args) throws Exception
>-	{
>-		if (args.length != 1)
>-		{
>-			System.err.println("missing command line argument");
>+    public static void main(String[] args) throws Exception {
>+        if (args.length != 1) {
>+            System.err.println("Usage: java CookieDemoApp <url>");
>+            System.err.println("<url> The url of a webpage");
> 			System.exit(1);
> 		}
> 		
>@@ -112,32 +110,29 @@
> 
> 		initialState.addCookie(ck);
> 
>-		HttpClient hc = new HttpClient();
>+        HttpClient client = new HttpClient();
>+        HostConfiguration hc = new HostConfiguration();
>+        hc.setHost(new URI(u));
>+        client.setHostConfiguration(hc);
> 		
>-		hc.startSession(u);
>+        client.setConnectionTimeout(30000);
>+        client.setState(initialState);
> 
>-		hc.setTimeout(30000 /* milliseconds */);
>-		hc.setState(initialState);
>-		
>-		for (int i = 0; i < 10; i++)
>-		{
>+        for (int i = 0; i < 10; i++) {
> 			GetMethod get = new GetMethod("/");
>-			int iResultCode = hc.executeMethod(get);
>-			HttpState state = hc.getState();
>+            int iResultCode = client.executeMethod(get);
>+            HttpState state = client.getState();
> 			Cookie[] cookies = state.getCookies();
>-			for (int k = 0; k < cookies.length; k++)
>-			{
>+            for (int k = 0; k < cookies.length; k++) {
> 				Cookie currentCookie = cookies[k];
>-				if (currentCookie.getName().equals(COOKIE_NAME))
>-				{
>+                if (currentCookie.getName().equals(COOKIE_NAME)) {
> 					Integer iCount = new Integer(currentCookie.getValue());
> 					System.out.println("count value is : " + iCount);
> 					int iNewCount = iCount.intValue() + 1;
> 					currentCookie.setValue("" + iNewCount);
> 				}
> 			}
>+            get.releaseConnection();
> 		}
>-		
>-		hc.endSession();
> 	}
> }
>Index: MultipartFileUploadApp.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/MultipartFileUploadApp.java,v
>retrieving revision 1.1
>diff -u -w -r1.1 MultipartFileUploadApp.java
>--- MultipartFileUploadApp.java	12 Oct 2002 04:36:32 -0000	1.1
>+++ MultipartFileUploadApp.java	16 Dec 2002 17:13:17 -0000
>@@ -1,5 +1,5 @@
> /*
>- * $Header $
>+ * $Header:$
>  * $Revision: 1.2 $
>  * $Date:  $
>  * 
>@@ -81,11 +81,9 @@
>  * @author Sean C. Sullivan
>  *
>  */
>-public class MultipartFileUploadApp
>-{
>+public class MultipartFileUploadApp {
> 
>-	public static void main(String[] args)
>-	{
>+    public static void main(String[] args) {
> 		MultipartFileUploadMainFrame f = new MultipartFileUploadMainFrame();
> 		f.setTitle("HTTP multipart file upload application");
> 		f.setSize(700, 500);
>@@ -93,19 +91,16 @@
> 		f.setVisible(true);
> 	}
> 
>-	public static class MultipartFileUploadMainFrame extends javax.swing.JFrame
>-	{
>+    public static class MultipartFileUploadMainFrame extends javax.swing.JFrame {
> 		private MultipartFileUploadPanel m_panel;
> 
>-		public MultipartFileUploadMainFrame()
>-		{
>+        public MultipartFileUploadMainFrame() {
> 			m_panel = new MultipartFileUploadPanel();
> 			this.getContentPane().add(m_panel);
> 		}
> 	}
> 
>-	public static class MultipartFileUploadPanel extends JPanel
>-	{
>+    public static class MultipartFileUploadPanel extends JPanel {
> 		private static final String strTenSpaces = "          ";
> 		private static final String strFortySpaces =
> 			strTenSpaces + strTenSpaces + strTenSpaces + strTenSpaces;
>@@ -114,12 +109,10 @@
> 
> 		private File targetFile = null;
> 		
>-		public MultipartFileUploadPanel()
>-		{
>+        public MultipartFileUploadPanel() {
> 			final JPanel panInput = new JPanel();
> 			
>-			String[] aURLs =
>-				{
>+            String[] aURLs = {
> 					"http://localhost:8080/foo/bar"
> 				};
> 
>@@ -136,18 +129,15 @@
> 			btnDoUpload.setEnabled(false);
> 
> 			final JButton btnSelectFile = new JButton("Select a file...");
>-			btnSelectFile.addActionListener(new ActionListener()
>-				{
>-					public void actionPerformed(final ActionEvent evt)
>-					{
>+            btnSelectFile.addActionListener(new ActionListener() {
>+                    public void actionPerformed(final ActionEvent evt) {
> 						final JFileChooser chooser = new JFileChooser();
> 						chooser.setFileHidingEnabled(false);
> 						chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
> 						chooser.setMultiSelectionEnabled(false);
> 						chooser.setDialogType(JFileChooser.OPEN_DIALOG);
> 						chooser.setDialogTitle("Choose a file...");
>-						if (chooser.showOpenDialog(MultipartFileUploadPanel.this) == JFileChooser.APPROVE_OPTION)
>-						{
>+                        if (chooser.showOpenDialog(MultipartFileUploadPanel.this) ==
JFileChooser.APPROVE_OPTION) {
> 							targetFile = chooser.getSelectedFile();
> 							lblTargetFile.setText("Selected file:  " + targetFile.toString());
> 							btnDoUpload.setEnabled(true);
>@@ -162,54 +152,42 @@
> 			final JLabel lblURL = new JLabel("URL:");
> 
> 
>-			btnDoUpload.addActionListener(new ActionListener()
>-			{
>-				public void actionPerformed(ActionEvent ae)
>-				{
>+            btnDoUpload.addActionListener(new ActionListener() {
>+                public void actionPerformed(ActionEvent ae) {
> 					URL targetURL = null;
> 
>-					try
>-					{					
>+                    try {
> 						targetURL = new URL(cmbURL.getSelectedItem().toString());
>-					}
>-					catch (MalformedURLException ex)
>-					{
>+                    } catch (MalformedURLException ex) {
> 						// todo - code here
> 						ex.printStackTrace();
> 					}
> 
> 										
> 					MultipartPostMethod filePost = new MultipartPostMethod();
>-					if (targetURL.getPath() == null)
>-					{
>+                    if (targetURL.getPath() == null) {
> 						filePost.setPath("/");
>-					}
>-					else
>-					{
>+                    } else {
> 						filePost.setPath(targetURL.getPath());
> 					}
> 					
>-					try
>-					{
>+                    try {
> 						filePost.addParameter(
> 								targetFile.getName(),
> 								targetFile);
> 						HttpClient client = new HttpClient();
>-						client.startSession(targetURL);
>+                        HostConfiguration hc = new HostConfiguration();
>+                        hc.setHost(new URI(targetURL));
>+                        client.setHostConfiguration(hc);
> 						client.executeMethod(filePost);
>-					}
>-					catch (FileNotFoundException ex)
>-					{
>+                        filePost.releaseConnection();
>+                    } catch (FileNotFoundException ex) {
> 						// todo - put real code here
> 						ex.printStackTrace();
>-					}
>-					catch (HttpException ex)
>-					{
>+                    } catch (HttpException ex) {
> 						// todo - put real code here
> 						ex.printStackTrace();
>-					}
>-					catch (java.io.IOException ex)
>-					{
>+                    } catch (java.io.IOException ex) {
> 						// todo - put real code here
> 						ex.printStackTrace();
> 					}
>Index: PostXML.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/PostXML.java,v
>retrieving revision 1.3
>diff -u -w -r1.3 PostXML.java
>--- PostXML.java	8 Sep 2002 05:19:06 -0000	1.3
>+++ PostXML.java	16 Dec 2002 17:13:17 -0000
>@@ -75,10 +75,9 @@
>  * to a remote web server using HTTP POST
>  * 
>  * @author Sean C. Sullivan
>- *
>+ * @author Ortwin Glück
>  */
>-public class PostXML 
>-{
>+public class PostXML {
> 
>     /**
>      *  
>@@ -90,11 +89,14 @@
>      *                 Argument 1 is a local filename
>      * 
>      */
>-	public static void main(String[] args) throws Exception
>-	{
>-		if (args.length != 2)
>-		{
>-			System.err.println("missing command line arguments");
>+    public static void main(String[] args) throws Exception {
>+        if (args.length != 2) {
>+            System.out.println("Usage: java -classpath <classpath> [-Dorg.apache.commons.logging.simplelog.defaultlog=<loglevel>]
PostXML <url> <filename>]");
>+            System.out.println("<classpath> - must contain the commons-httpclient.jar
and commons-logging.jar");
>+            System.out.println("<loglevel> - one of error, warn, info, debug, trace");
>+            System.out.println("<url> - the URL to post the file to");
>+            System.out.println("<filename> - file to post to the URL");
>+            System.out.println();
> 			System.exit(1);
> 		}
> 		
>@@ -112,18 +114,17 @@
> 
> 		post.setRequestBody(input);
> 		
>-		if ( (u.getPath() == null) || (u.getPath().length() == 0) )
>-		{
>+        if ((u.getPath() == null) || (u.getPath().length() == 0)) {
> 			post.setPath("/");
> 		}
>-		else
>-		{
>+        else {
> 			post.setPath(u.getPath());
> 		}
> 		post.setRequestHeader("Content-type", "text/xml");
> 				
> 		HttpClient hc = new HttpClient();
>-		hc.startSession(u);
>+        HostConfiguration cfg = new HostConfiguration();
>+        cfg.setHost(new URI(u));
> 		
> 		int iResultCode = hc.executeMethod(post);
> 		
>@@ -135,6 +136,6 @@
> 		
> 		System.out.println( new String(yaResponse) );
> 
>-		hc.endSession();
>+        post.releaseConnection();
> 	}
> }
>Index: TrivialApp.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/TrivialApp.java,v
>retrieving revision 1.5
>diff -u -w -r1.5 TrivialApp.java
>--- TrivialApp.java	26 Nov 2002 10:16:03 -0000	1.5
>+++ TrivialApp.java	16 Dec 2002 17:13:17 -0000
>@@ -61,10 +61,20 @@
>  *
>  */
> 
>-import org.apache.commons.httpclient.*;
>-import org.apache.commons.httpclient.methods.*;
>-import java.net.*;
>-import java.io.*;
>+import java.io.IOException;
>+import java.net.MalformedURLException;
>+import java.net.URL;
>+
>+import org.apache.commons.httpclient.Credentials;
>+import org.apache.commons.httpclient.Header;
>+import org.apache.commons.httpclient.HostConfiguration;
>+import org.apache.commons.httpclient.HttpClient;
>+import org.apache.commons.httpclient.HttpException;
>+import org.apache.commons.httpclient.HttpMethod;
>+import org.apache.commons.httpclient.UsernamePasswordCredentials;
>+import org.apache.commons.httpclient.URI;
>+import org.apache.commons.httpclient.URIException;
>+import org.apache.commons.httpclient.methods.GetMethod;
> 
> /**
>  * 
>@@ -72,7 +82,7 @@
>  * how to use the Jakarta HttpClient API.
>  * 
>  * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
>- *
>+ * @author Ortwin Glück
>  */
> public class TrivialApp
> {
>@@ -120,8 +130,16 @@
>             client.getState().setCredentials(null, creds);
>         }
> 
>+        //
>+        HostConfiguration hc = new HostConfiguration();
>+        try {
>+            hc.setHost(new URI(url));
>+        } catch(URIException e) {
>+            throw new RuntimeException(e.toString());
>+        }
>+
>         //start a session with the webserver
>-        client.startSession(url);
>+        client.setHostConfiguration(hc);
> 
>         //create a method object
>         HttpMethod method = new GetMethod(url.getPath());
>@@ -164,6 +182,7 @@
>         for (int i=0; i<responseHeaders.length; i++){
>             System.out.print(responseHeaders[i]);
>         }
>+        method.releaseConnection();
> 
>         System.exit(0);
>     }
>  
>
>------------------------------------------------------------------------
>
>? patch.diff
>Index: org/apache/commons/httpclient/ChunkedOutputStream.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java,v
>retrieving revision 1.2
>diff -u -w -r1.2 ChunkedOutputStream.java
>Index: org/apache/commons/httpclient/HostConfiguration.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HostConfiguration.java,v
>retrieving revision 1.3
>diff -u -w -r1.3 HostConfiguration.java
>--- org/apache/commons/httpclient/HostConfiguration.java	16 Dec 2002 03:51:03 -0000	1.3
>+++ org/apache/commons/httpclient/HostConfiguration.java	16 Dec 2002 17:14:04 -0000
>@@ -205,13 +205,25 @@
>         }
>         
>         this.host = host;
>-        this.port = port;
>+        this.port = port == -1 ? protocol.getDefaultPort() : port;
>         this.protocol = protocol;
>         
>         this.hostSet = true;
>         
>     }
> 
>+    /**
>+     * Sets the protocol, host and port from the given URI.
>+     * @param uri the URI.
>+     */
>+    public synchronized void setHost(URI uri) {
>+        try {
>+            setHost(uri.getHost(), uri.getPort(), uri.getScheme());
>+        } catch(URIException e) {
>+            throw new IllegalArgumentException(e.toString());
>+        }
>+    }
>+
>     public synchronized String getHostURL() {
>         
>         if ( !hostSet ) {
>Index: org/apache/commons/httpclient/HttpClient.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
>retrieving revision 1.63
>diff -u -w -r1.63 HttpClient.java
>--- org/apache/commons/httpclient/HttpClient.java	16 Dec 2002 03:51:03 -0000	1.63
>+++ org/apache/commons/httpclient/HttpClient.java	16 Dec 2002 17:14:04 -0000
>@@ -515,7 +515,7 @@
>         HostConfiguration methodConfiguration = new HostConfiguration(hostConfiguration);
>         
>         if ( hostConfiguration != defaultHostConfiguration ) {
>-            // we may need to appy some defaults
>+            // we may need to apply some defaults
>             if ( !methodConfiguration.isHostSet() ) {
>                 methodConfiguration.setHost(
>                     defaultHostConfiguration.getHost(),
>Index: org/apache/commons/httpclient/SimpleHttpConnectionManager.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java,v
>retrieving revision 1.3
>diff -u -w -r1.3 SimpleHttpConnectionManager.java
>--- org/apache/commons/httpclient/SimpleHttpConnectionManager.java	16 Dec 2002 03:51:04
-0000	1.3
>+++ org/apache/commons/httpclient/SimpleHttpConnectionManager.java	16 Dec 2002 17:14:04
-0000
>@@ -172,7 +172,7 @@
>                 lastResponse.close();
>             }
>             catch (IOException ioe) {
>-                // badness - close to force reconnect.
>+                //FIXME: badness - close to force reconnect.
>                 conn.close();
>             }
>         }
>Index: org/apache/commons/httpclient/URI.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java,v
>retrieving revision 1.14
>diff -u -w -r1.14 URI.java
>--- org/apache/commons/httpclient/URI.java	3 Nov 2002 17:15:05 -0000	1.14
>+++ org/apache/commons/httpclient/URI.java	16 Dec 2002 17:14:07 -0000
>@@ -69,6 +69,7 @@
> import java.util.Locale;
> import java.util.BitSet;
> import java.util.Hashtable;
>+import java.net.URL;
> import java.security.AccessController;
> import java.security.PrivilegedAction;
> import sun.security.action.GetBooleanAction;
>@@ -184,6 +185,16 @@
>         parseUriReference(original, false);
>     }
> 
>+    /**
>+     * Construct a URI from a URL.
>+     *
>+     * @param url a valid URL.
>+     * @throws URIException
>+     */
>+    public URI(URL url) throws URIException {
>+        this(url.toString());
>+    }
>+
> 
>     /**
>      * Construct a general URI from the given components.
>
>  
>
>------------------------------------------------------------------------
>
>--
>To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>
>


Mime
View raw message