当前位置: 首页>>代码示例>>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;未经允许,请勿转载。