当前位置: 首页>>代码示例>>Java>>正文


Java StaplerRequest.getHeader方法代码示例

本文整理汇总了Java中org.kohsuke.stapler.StaplerRequest.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerRequest.getHeader方法的具体用法?Java StaplerRequest.getHeader怎么用?Java StaplerRequest.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kohsuke.stapler.StaplerRequest的用法示例。


在下文中一共展示了StaplerRequest.getHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doPost

import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
public HttpResponse doPost(StaplerRequest request) throws IOException {
    if (!request.getMethod().equals("POST")) {
        return HttpResponses
                .error(HttpServletResponse.SC_BAD_REQUEST,
                        "Only POST requests are supported, this was a " + request.getMethod() + " request");
    }
    if (!"application/json".equals(request.getContentType())) {
        return HttpResponses
                .error(HttpServletResponse.SC_BAD_REQUEST,
                        "Only application/json content is supported, this was " + request.getContentType());
    }
    String type = request.getHeader("X-Gitea-Event");
    if (StringUtils.isBlank(type)) {
        return HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST,
                "Expecting a Gitea event, missing expected X-Gitea-Event header");
    }
    String origin = SCMEvent.originOf(request);
    boolean processed = false;
    for (GiteaWebhookHandler<?, ?> h : ExtensionList.lookup(GiteaWebhookHandler.class)) {
        if (h.matches(type)) {
            h.process(request.getInputStream(), origin);
            processed = true;
        }
    }
    return HttpResponses.plainText(processed ? "Processed" : "Ignored");
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:27,代码来源:GiteaWebhookAction.java

示例2: generateResponse

import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
/**
 * TO DO
 * @param req
 * @param rsp
 * @param node
 * @throws IOException
 * @throws ServletException
 */
@Override
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
    // Check if the latest badge is already cached
	String v = req.getHeader("If-None-Match");
    if (etag.equals(v)) {
        rsp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        return;
    }

    rsp.setHeader("ETag", etag);
    rsp.setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT");
    rsp.setHeader("Cache-Control", "no-cache, private");
    rsp.setHeader("Content-Type", "image/svg+xml;charset=utf-8");
    rsp.setHeader("Content-Length", length);
    rsp.getOutputStream().write(payload);
}
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:25,代码来源:StatusImage.java


注:本文中的org.kohsuke.stapler.StaplerRequest.getHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。