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


Java HttpResponse.addHeader方法代碼示例

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


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

示例1: sendPrepare

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
private HttpResponse sendPrepare(ChannelHandlerContext ctx,String body) {
	HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
	response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
	response.addHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
	StringBuilder builder = new StringBuilder();
	builder.append(body);

	response.setContent(ChannelBuffers.copiedBuffer(builder.toString(), CharsetUtil.UTF_8));
	return response;
}
 
開發者ID:violetgo,項目名稱:wifidogAuthServer,代碼行數:11,代碼來源:HttpHandler.java

示例2: setCookies

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
private void setCookies(Renderer renderer, HttpResponse response) {
    if (renderer != null) {
        for (Iterator<HttpCookie> it = renderer.getApp().getCookieEncoder().iterator(); it.hasNext();) {
            HttpCookie httpCookie = it.next();
            CookieEncoder encoder = new CookieEncoder(false);
            encoder.addCookie(httpCookie.getName(), httpCookie.getValue());
            response.addHeader("Set-Cookie", httpCookie.toString()+"; path=/");
        }
    }
}
 
開發者ID:govu,項目名稱:govu,代碼行數:11,代碼來源:HttpServerHandler.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

示例7: movedPermanently

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
@Override
public void movedPermanently(String location) {
    HttpResponse response = new DefaultHttpResponse(HTTP_1_1, MOVED_PERMANENTLY);
    response.addHeader("Location", location);
    write(response);
}
 
開發者ID:neilbeveridge,項目名稱:zuul-netty,代碼行數:7,代碼來源:InterruptsImpl.java

示例8: temporaryRedirect

import org.jboss.netty.handler.codec.http.HttpResponse; //導入方法依賴的package包/類
@Override
public void temporaryRedirect(String location) {
    HttpResponse response = new DefaultHttpResponse(HTTP_1_1, TEMPORARY_REDIRECT);
    response.addHeader("Location", location);
    write(response);
}
 
開發者ID:neilbeveridge,項目名稱:zuul-netty,代碼行數:7,代碼來源:InterruptsImpl.java


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