Back to project page khandroid.
The source code is released under:
Apache License
If you think the Android project khandroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.khandroid.http.request; //from w ww.j a v a 2s .c om import java.net.URI; import java.net.URISyntaxException; import khandroid.ext.apache.http.client.methods.HttpGet; import khandroid.ext.apache.http.client.methods.HttpUriRequest; import khandroid.ext.apache.http.client.utils.URIBuilder; import khandroid.ext.apache.http.client.utils.URLEncodedUtils; public class GetRequestBuilder extends RequestBuilder { public GetRequestBuilder(String url) { super(url); } @Override public HttpUriRequest build() { HttpGet ret = null; String protocol = getProtocol(); if (protocol != null && !protocol.equals("") && getDomain() != null && !getDomain().equals("") && getPath() != null && !getPath().equals("")) { URI uri; try { URIBuilder ub = new URIBuilder(); ub.setScheme(protocol).setHost(getDomain()).setPort(getPort()).setPath(getPath()); ub.setQuery(URLEncodedUtils.format(getGetParams(), "UTF-8")); uri = ub.build(); } catch (URISyntaxException e) { throw new IllegalStateException("Error creating URI.", e); } ret = new HttpGet(uri); ret.addHeader("Accept-Charset", "UTF-8,*"); } else { throw new IllegalStateException(String.format("Some of required fields (protocol (%s), domain (%s), path(%s)) are empty.", getProtocol(), getDomain(), getPath())); } return ret; } }