本文整理汇总了Java中org.elasticsearch.rest.RestRequest.putHeader方法的典型用法代码示例。如果您正苦于以下问题:Java RestRequest.putHeader方法的具体用法?Java RestRequest.putHeader怎么用?Java RestRequest.putHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.rest.RestRequest
的用法示例。
在下文中一共展示了RestRequest.putHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
public void process(RestRequest request, RestChannel channel, RestFilterChain filterChain) {
LoginUserContext user = null;
request.putInContext(RestRequest.REQUEST_START_TIME, System.currentTimeMillis());
try {
user = new LoginUserContext(request, clusterService);
} catch (NoPermissionException e) {
logger.info("errors while parsing userinfo from request, error msg is [{}]", e.getMessage());
ResponseUtil.send(channel, RestStatus.UNAUTHORIZED, e.getMessage());
return;
}
if (user.loginUsername() == null || user.loginUsername().length() ==0) {
ResponseUtil.send(channel, RestStatus.UNAUTHORIZED, "Username is empty");
logger.info("Username is empty");
}
if (!user.authenticated() && (user.password() == null || user.password().length() ==0)) {
ResponseUtil.send(channel, RestStatus.UNAUTHORIZED, "Password is empty");
logger.info("Password is empty");
}
// put user info into context
request.putHeader(LoginUserContext.USER_INFO_KEY, user);
filterChain.continueProcessing(request, channel);
}