1 19 20 package com.maverick.http; 21 22 import java.util.Enumeration ; 23 import java.util.Vector ; 24 25 import com.maverick.util.URLUTF8Encoder; 26 27 31 public class GetMethod extends HttpMethod { 32 33 38 public GetMethod(String uri) { 39 super("GET", uri); } 41 42 public GetMethod(String name, String uri) { 43 super(name, uri); 44 } 45 46 public String getURI() { 47 48 String encodedParams = ""; for (Enumeration e = getParameterNames(); e.hasMoreElements();) { 50 String name = (String ) e.nextElement(); 51 Vector values = getParameterValueList(name); 52 for (Enumeration e2 = values.elements(); e2.hasMoreElements();) { 53 String value = (String ) e2.nextElement(); 54 encodedParams += (encodedParams.length() > 0 ? "&" : "") + URLUTF8Encoder.encode(name, true) + "=" + URLUTF8Encoder.encode(value, true); 56 } 57 } 58 59 if (super.getURI().indexOf('?') > 0 && encodedParams.length() > 0) 60 return super.getURI() + "&" + encodedParams; else 62 return super.getURI() + (encodedParams.length() > 0 ? ("?" + encodedParams) : ""); } 64 } 65 | Popular Tags |