org.frameworkset.spi.remote.http.HttpReqeust Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bboss-http Show documentation
Show all versions of bboss-http Show documentation
bboss http an http cluster lb component.
/*
* Copyright 2008 biaoping.yin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.frameworkset.spi.remote.http;
import java.io.File;
import java.util.Map;
/**
*
* Title: HttpReqeust.java
*
*
* Description:
*
*
* bboss workgroup
*
*
* Copyright (c) 2007
*
*
* @Date 2014年4月9日 上午10:02:37
* @author biaoping.yin
* @version 1.0
*/
public class HttpReqeust {
public static String httpGetforString(String url) throws Exception {
return httpGetforString(url, (String)null,
(String)null);
}
/**
* get请求URL
*
* @param url
* @param cookie
* @param userAgent
* @throws Exception
*/
public static String httpGetforString(String url, String cookie,
String userAgent) throws Exception {
return HttpRequestUtil.httpGetforString(url, cookie, userAgent,null);
// //responseBody = responseBody.replaceAll("\\p{Cntrl}", "\r\n");
// if(responseBody.contains("result") &&
// responseBody.contains("errorCode") &&
// appContext.containsProperty("user.uid")){
// try {
// Result res = Result.parse(new
// ByteArrayInputStream(responseBody.getBytes()));
// if(res.getErrorCode() == 0){
// appContext.Logout();
// appContext.getUnLoginHandler().sendEmptyMessage(1);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// return new ByteArrayInputStream(responseBody.getBytes());
}
/**
* 公用post方法
*
* @param url
* @param params
* @param files
* @throws Exception
*/
public static String httpPostforString(String url,Map params,
Map files) throws Exception
{
return httpPostforString(url, (String)null,
(String) null,params,
files) ;
}
/**
* 公用post方法
*
* @param url
* @param files
* @throws Exception
*/
public static String httpPostforFile(String url,
Map files) throws Exception
{
return httpPostforString(url, (String)null,
(String) null,null,
files) ;
}
/**
* 公用post方法
*
* @param url
* @param params
* @throws Exception
*/
public static String httpPostforString(String url,Map params) throws Exception
{
return httpPostforString(url, (String)null,
(String) null,params,
(Map)null) ;
}
/**
* 公用post方法
*
* @param url
* @throws Exception
*/
public static String httpPostforString(String url) throws Exception
{
return httpPostforString(url, (String)null,
(String) null,(Map)null,
(Map)null) ;
}
/**
* 公用post方法:文件上传方法
*
* @param url
* @param params
* @param files
* @throws Exception
*/
public static String httpPostforString(String url, String cookie,
String userAgent, Map params,
Map files) throws Exception {
return HttpRequestUtil.httpPostforString(url, cookie, userAgent,params,files);
// responseBody = responseBody.replaceAll("\\p{Cntrl}", "");
// if(responseBody.contains("result") &&
// responseBody.contains("errorCode") &&
// appContext.containsProperty("user.uid")){
// try {
// Result res = Result.parse(new
// ByteArrayInputStream(responseBody.getBytes()));
// if(res.getErrorCode() == 0){
// appContext.Logout();
// appContext.getUnLoginHandler().sendEmptyMessage(1);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// return new ByteArrayInputStream(responseBody.getBytes());
}
/**
* 公用post方法:文件上传方法
*
* @param url
* @param cookie
* @param userAgent
* @param files
* @throws Exception
*/
public static String httpPostforString(String url, String cookie,
String userAgent,
Map files) throws Exception {
return HttpRequestUtil.httpPostforString(url, cookie, userAgent,files);
// responseBody = responseBody.replaceAll("\\p{Cntrl}", "");
// if(responseBody.contains("result") &&
// responseBody.contains("errorCode") &&
// appContext.containsProperty("user.uid")){
// try {
// Result res = Result.parse(new
// ByteArrayInputStream(responseBody.getBytes()));
// if(res.getErrorCode() == 0){
// appContext.Logout();
// appContext.getUnLoginHandler().sendEmptyMessage(1);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// return new ByteArrayInputStream(responseBody.getBytes());
}
}