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 HeadMethod.
41 *
42 * @deprecated use HeadMethod
43 *
44 * @author Marc A. Saegesser
45 * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
46 */
47 public class UrlHeadMethod extends HeadMethod implements HttpUrlMethod {
48
49 /*** The URL */
50 private String url;
51
52 /***
53 * No-arg constructor.
54 */
55 public UrlHeadMethod() {
56 super();
57 }
58
59
60 /***
61 * Path-setting constructor.
62 * @param url the path of the request
63 * @throws MalformedURLException If the url isn't valid.
64 */
65 public UrlHeadMethod(String url) throws MalformedURLException {
66 super(URIUtil.getPath(url));
67 setUrl(url);
68 }
69
70 /***
71 * Sets the URL. Calls the underlying HttpMethod.setPath()
72 * with the url's path. If the url contains a query string
73 * the underlying HttpMethod.setQueryString() is called.
74 *
75 * @param url - the URL for this request.
76 * @throws MalformedURLException If the url isn't valid.
77 */
78 public void setUrl(String url) throws MalformedURLException {
79 super.setPath(URIUtil.getPath(url));
80 this.url = url;
81 String query = URIUtil.getQuery(url);
82 if (query != null && query.length() > 0) {
83 super.setQueryString(query);
84 }
85 }
86
87 /***
88 * Returns this request's URL.
89 *
90 * @return the request's URL.
91 */
92 public String getUrl() {
93 return url;
94 }
95 }
96