1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package org.apache.commons.httpclient.methods;
33
34 import org.apache.commons.httpclient.HttpUrlMethod;
35 import org.apache.commons.httpclient.util.URIUtil;
36
37 import java.net.MalformedURLException;
38
39 /***
40 * HttpUrlMethod version of PostMethod.
41 *
42 * @deprecated use PostMethod
43 *
44 * @author Marc A. Saegesser
45 * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
46 */
47 public class UrlPostMethod extends PostMethod implements HttpUrlMethod {
48
49 /*** The URL */
50 private String url;
51
52 /***
53 * No-arg constructor.
54 */
55 public UrlPostMethod() {
56 super();
57 }
58
59 /***
60 * Path-setting constructor.
61 * @param url the URL to request
62 * @throws MalformedURLException If the url isn't valid.
63 */
64 public UrlPostMethod(String url) throws MalformedURLException {
65 super(URIUtil.getPath(url));
66 setUrl(url);
67 }
68
69 /***
70 * Constructor.
71 * @param url the URL to request
72 * @param tempDir directory to store temp files in
73 * @throws MalformedURLException If the url isn't valid.
74 */
75 public UrlPostMethod(String url, String tempDir) throws MalformedURLException {
76 super(URIUtil.getPath(url), tempDir);
77 setUrl(url);
78 }
79
80 /***
81 * Constructor.
82 * @param url the URL to request
83 * @param tempDir directory to store temp files in
84 * @param tempFile file to store temporary data in
85 * @throws MalformedURLException If the url isn't valid.
86 */
87 public UrlPostMethod(String url, String tempDir, String tempFile)
88 throws MalformedURLException {
89 super(URIUtil.getPath(url), tempDir, tempFile);
90 setUrl(url);
91 }
92
93 /***
94 * Sets the URL. Calls the underlying HttpMethod.setPath()
95 * with the url's path. If the url contains a query string
96 * the underlying HttpMethod.setQueryString() is called.
97 *
98 * @param url - the URL for this request.
99 * @throws MalformedURLException If the url isn't valid.
100 */
101 public void setUrl(String url) throws MalformedURLException {
102 super.setPath(URIUtil.getPath(url));
103 this.url = url;
104 String query = URIUtil.getQuery(url);
105 if (query != null && query.length() > 0) {
106 super.setQueryString(query);
107 }
108 }
109
110 /***
111 * Returns this request's URL.
112 *
113 * @return the request's URL.
114 */
115 public String getUrl() {
116 return url;
117 }
118 }
119