當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponse.setStatus方法代碼示例

本文整理匯總了Java中org.jboss.netty.handler.codec.http.HttpResponse.setStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponse.setStatus方法的具體用法?Java HttpResponse.setStatus怎麽用?Java HttpResponse.setStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.handler.codec.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.setStatus方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
public boolean process(HttpRequest request, HttpResponse response)
    throws Exception {
    String uri = request.getUri();
    if (uri.equalsIgnoreCase(FAVICON)) {
        response.setStatus(HttpResponseStatus.NOT_FOUND);
        log.warn("favicon.ico isn't found!");
        response.setContent(ChannelBuffers.copiedBuffer(HttpResponseStatus.NOT_FOUND.toString(), CharsetUtil.UTF_8));
        return false;
    }

    return true;
}
 
開發者ID:sunguangran,項目名稱:navi,代碼行數:13,代碼來源:FaviousRequestLister.java

示例2: process

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
public boolean process(HttpRequest request, HttpResponse response) throws Exception {
    if (request instanceof NaviHttpServerCodec.NaviBadRequest) {
        // 無效HTTP協議請求
        response.setStatus(HttpResponseStatus.BAD_REQUEST);
        NaviHttpServerCodec.NaviBadRequest badRequest = (NaviHttpServerCodec.NaviBadRequest) request;
        log.error(badRequest.getT().getMessage(), badRequest.getT());

        return false;
    }

    return true;
}
 
開發者ID:sunguangran,項目名稱:navi,代碼行數:13,代碼來源:NoNormalRequestLister.java

示例3: submitByHtml

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
/**
 * @param ctx
 * @param content
 * @param response
 * @return
 */
private HttpResponse submitByHtml(ChannelHandlerContext ctx, QueryStringDecoder content, HttpResponse response) {
	String wifiname = HttpParameterHelper.getParameters(content, "wifiname");
	String wifipass = HttpParameterHelper.getParameters(content, "wifipass");
	LogHelper.info("get rededit user:"+wifiname+" pass:"+wifipass);
	if(wifiname.contains("'") || wifiname.contains("\"")){
		LogHelper.info("get rededit 不合法字符");
		response = returnRegeditPage(ctx, content,"不合法字符!");
		return response;
	}
	
	if(wifipass.contains("'") || wifipass.contains("\"")){
		LogHelper.info("get rededit 不合法字符");
		response = returnRegeditPage(ctx, content,"不合法字符!");
		return response;
	}
	SqlSession session = null;
	try{
		SqlSessionFactory factory = SessionFactory.getInstance();
		session = factory.openSession();
		UserMapper userMapper = session.getMapper(UserMapper.class);
		List<User> result = userMapper.select(wifiname);

		if(result!=null && result.size()!=0){
			LogHelper.info("get rededit 用戶名存在");
			response = returnLoginPage(ctx, content,"用戶名存在!");
			return response;
		}
		
		User user = new User();
		user.setUsername(wifiname);
		user.setPassword(wifipass);
		user.setCreatetime(new Date());
		userMapper.insert(user);
		
		String redirectUrl="http://"+HttpParameterHelper.getParameters(content, "gw_address")+":"+HttpParameterHelper.getParameters(content, "gw_port")+"/wifidog/auth?"+"token="+wifiname+"&url="+HttpParameterHelper.getParameters(content, "url");
		LogHelper.info("get rededit redirecturl:"+redirectUrl);
		
		response = sendPrepare(ctx, "");
		response.setStatus(HttpResponseStatus.TEMPORARY_REDIRECT);
		response.addHeader(HttpHeaders.Names.LOCATION, redirectUrl);
	}catch(Exception e){
		LogHelper.error(ExceptionUtils.getFullStackTrace(e));
	}finally{
		if(session!=null){
			session.close();
		}
	}
	return response;
}
 
開發者ID:violetgo,項目名稱:wifidogAuthServer,代碼行數:56,代碼來源:HttpHandler.java

示例4: submitByApp

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
/**
 * @param ctx
 * @param content
 * @param response
 * @return
 */
private HttpResponse submitByApp(ChannelHandlerContext ctx, QueryStringDecoder content, HttpResponse response) {
	String wifiname = HttpParameterHelper.getParameters(content, "wifiname");
	String wifipass = HttpParameterHelper.getParameters(content, "wifipass");
	LogHelper.info("get rededit user:"+wifiname+" pass:"+wifipass);
	if(wifiname.contains("'") || wifiname.contains("\"")){
		LogHelper.info("get rededit 不合法字符");
		response = sendPrepare(ctx, "{errorcode:000001}");
		return response;
	}
	
	if(wifipass.contains("'") || wifipass.contains("\"")){
		LogHelper.info("get rededit 不合法字符");
		response = sendPrepare(ctx, "{errorcode:000001}");
		return response;
	}
	SqlSession session = null;
	try{
		SqlSessionFactory factory = SessionFactory.getInstance();
		session = factory.openSession();
		UserMapper userMapper = session.getMapper(UserMapper.class);
		List<User> result = userMapper.select(wifiname);

		if(result!=null && result.size()!=0){
			LogHelper.info("get rededit 用戶名存在");
			response = sendPrepare(ctx, "{errorcode:000005}");
			return response;
		}
		
		User user = new User();
		user.setUsername(wifiname);
		user.setPassword(wifipass);
		user.setCreatetime(new Date());
		userMapper.insert(user);
		
		String redirectUrl="http://"+HttpParameterHelper.getParameters(content, "gw_address")+":"+HttpParameterHelper.getParameters(content, "gw_port")+"/wifidog/auth?"+"token="+wifiname+"&url="+HttpParameterHelper.getParameters(content, "url");
		LogHelper.info("get rededit redirecturl:"+redirectUrl);
		
		response = sendPrepare(ctx, "");
		response.setStatus(HttpResponseStatus.TEMPORARY_REDIRECT);
		response.addHeader(HttpHeaders.Names.LOCATION, redirectUrl);
	}catch(Exception e){
		LogHelper.error(ExceptionUtils.getFullStackTrace(e));
	}finally{
		if(session!=null){
			session.close();
		}
	}
	return response;
}
 
開發者ID:violetgo,項目名稱:wifidogAuthServer,代碼行數:56,代碼來源:HttpHandler.java

示例5: loginByHtml

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
/**
	 * @param ctx
	 * @param content
	 * @param response
	 * @return
	 */
	private HttpResponse loginByHtml(ChannelHandlerContext ctx, QueryStringDecoder content, HttpResponse response) {
		String wifiname = HttpParameterHelper.getParameters(content, "wifiname");
		String wifipass = HttpParameterHelper.getParameters(content, "wifipass");
		LogHelper.info("get login user:"+wifiname+" pass:"+wifipass);
		
		if(wifiname.trim().equals("") || wifipass.trim().equals("")){
			LogHelper.info("get login 不合法字符");
			response = returnLoginPage(ctx, content,"不合法字符!");
			return response;
		}
		
		if(wifiname.contains("'") || wifiname.contains("\"")){
			LogHelper.info("get login 不合法字符");
			response = returnLoginPage(ctx, content,"不合法字符!");
			return response;
		}
		
		SqlSessionFactory factory = SessionFactory.getInstance();
		SqlSession session = null;
		try{
			session = factory.openSession();
			UserMapper userMapper = session.getMapper(UserMapper.class);
			List<User> result = userMapper.select(wifiname);
			if(result==null || result.size()==0){
				LogHelper.info("get login 用戶名錯誤");
				response = returnLoginPage(ctx, content,"用戶名密碼錯誤!");
				return response;
			}
			
			if(!result.get(0).getPassword().equals(wifipass)){
				LogHelper.info("get login 密碼錯誤");
				response = sendPrepare(ctx, "用戶名密碼錯誤!");
				return response;
			}
			
//			UserLogMapper logMapper = session.getMapper(UserLogMapper.class);
//			List<UserLog> log = logMapper.select(wifiname);
//			if(log!=null && log.size()>0 && log.get(0).getIsonline()==1){
//				LogHelper.info("用戶已經登錄...");
//				response = returnLoginPage(ctx, content,"用戶已經登錄...");
//				return response;
//			}

			String redirectUrl="http://"+HttpParameterHelper.getParameters(content, "gw_address")+":"+HttpParameterHelper.getParameters(content, "gw_port")+"/wifidog/auth?"+"token="+wifiname+"&url="+HttpParameterHelper.getParameters(content, "url");
			response = sendPrepare(ctx, "");
			response.setStatus(HttpResponseStatus.TEMPORARY_REDIRECT);
			response.addHeader(HttpHeaders.Names.LOCATION, redirectUrl);
			LogHelper.info("redirectUrl is  : "+redirectUrl);
			
		}catch(Exception e){
			LogHelper.error(ExceptionUtils.getFullStackTrace(e));
		}finally{
			if(session!=null){
				session.close();
			}
			
		}
		return response;
	}
 
開發者ID:violetgo,項目名稱:wifidogAuthServer,代碼行數:66,代碼來源:HttpHandler.java

示例6: loginByApp

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
private HttpResponse loginByApp(ChannelHandlerContext ctx, QueryStringDecoder content, HttpResponse response) {
		String wifiname = HttpParameterHelper.getParameters(content, "wifiname");
		String wifipass = HttpParameterHelper.getParameters(content, "wifipass");
		LogHelper.info("get login by app user:"+wifiname+" pass:"+wifipass);
		
		if(wifiname.trim().equals("") || wifipass.trim().equals("")){
			LogHelper.info("get login 不合法字符");
			response = sendPrepare(ctx, "{errorcode:000001}");
			return response;
		}
		
		if(wifiname.contains("'") || wifiname.contains("\"")){
			LogHelper.info("get login 不合法字符");
			response = sendPrepare(ctx, "{errorcode:000001}");
			return response;
		}
		
		SqlSessionFactory factory = SessionFactory.getInstance();
		SqlSession session = null;
		try{
			session = factory.openSession();
			UserMapper userMapper = session.getMapper(UserMapper.class);
			List<User> result = userMapper.select(wifiname);
			if(result==null || result.size()==0){
				LogHelper.info("get login 用戶名錯誤");
				response = sendPrepare(ctx, "{errorcode:000002}");
				return response;
			}
			
			if(!result.get(0).getPassword().equals(wifipass)){
				LogHelper.info("get login 密碼錯誤");
				response = sendPrepare(ctx, "{errorcode:000003}");
				return response;
			}
			
//			UserLogMapper logMapper = session.getMapper(UserLogMapper.class);
//			List<UserLog> log = logMapper.select(wifiname);
//			if(log!=null && log.size()>0 && log.get(0).getIsonline()==1){
//				LogHelper.info("用戶已經登錄...");
//				response = sendPrepare(ctx, "{errorcode:000004}");
//				return response;
//			}

			String redirectUrl="http://"+HttpParameterHelper.getParameters(content, "gw_address")+":"+HttpParameterHelper.getParameters(content, "gw_port")+"/wifidog/auth?"+"token="+wifiname+"&url="+HttpParameterHelper.getParameters(content, "url");
			response = sendPrepare(ctx, "");
			response.setStatus(HttpResponseStatus.TEMPORARY_REDIRECT);
			response.addHeader(HttpHeaders.Names.LOCATION, redirectUrl);
			LogHelper.info("redirectUrl is  : "+redirectUrl);
			
		}catch(Exception e){
			LogHelper.error(ExceptionUtils.getFullStackTrace(e));
		}finally{
			if(session!=null){
				session.close();
			}
			
		}
		return response;
	}
 
開發者ID:violetgo,項目名稱:wifidogAuthServer,代碼行數:60,代碼來源:HttpHandler.java


注:本文中的org.jboss.netty.handler.codec.http.HttpResponse.setStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。