org.onetwo.common.http.DefaultURLFetch Maven / Gradle / Ivy
package org.onetwo.common.http;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.onetwo.common.utils.MyUtils;
import org.onetwo.common.utils.StringUtils;
@SuppressWarnings("unchecked")
public class DefaultURLFetch implements URLFetch {
private String basic;
private HttpProxy proxy;
public DefaultURLFetch(){
}
public DefaultURLFetch(String basic){
this.basic = basic;
}
public DefaultURLFetch(String basic, String proxyHost, int proxyPort){
this.basic = basic;
if(StringUtils.isNotBlank(proxyHost)){
this.proxy = new HttpProxy(proxyHost, proxyPort<=0?80:proxyPort);
}
}
public DefaultURLFetch(HttpProxy proxy){
this.proxy = proxy;
}
public DefaultURLFetch(String basic, HttpProxy proxy){
this.basic = basic;
this.proxy = proxy;
}
public HttpResponse fetch(HttpRequest request){
return fetch(request, HttpRequest.GET);
}
public HttpResponse fetch(HttpRequest request, String method){
if(HttpRequest.POST.equals(method))
request.post();
else
request.get();
HttpResponse response = new HttpResponse(request.getHttpConnection());
return response;
}
public HttpResponse get(String url){
return get(url, false);
}
public HttpResponse get(String url, String encode){
return get(url, false, HttpRequest.ENCODE_KEY, encode);
}
public HttpResponse get(String url, boolean verify){
return get(url, verify, (Object[])null);
}
protected String parseParmas(Map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy