javax.servlet.http.HttpServlet.doHead()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中javax.servlet.http.HttpServlet.doHead()方法的一些代码示例,展示了HttpServlet.doHead()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServlet.doHead()方法的具体详情如下:
包路径:javax.servlet.http.HttpServlet
类名称:HttpServlet
方法名:doHead

HttpServlet.doHead介绍

[英]Receives an HTTP HEAD request from the protected service method and handles the request. The client sends a HEAD request when it wants to see only the headers of a response, such as Content-Type or Content-Length. The HTTP HEAD method counts the output bytes in the response to set the Content-Length header accurately.

If you override this method, you can avoid computing the response body and just set the response headers directly to improve performance. Make sure that the doHead method you write is both safe and idempotent (that is, protects itself from being called multiple times for one HTTP HEAD request).

If the HTTP HEAD request is incorrectly formatted, doHead returns an HTTP "Bad Request" message.
[中]从受保护的service方法接收HTTP头请求并处理该请求。当客户端只想查看响应的头(如内容类型或内容长度)时,会发送一个头请求。HTTP HEAD方法计算响应中的输出字节数,以准确设置内容长度标头。
如果重写此方法,则可以避免计算响应体,而直接设置响应头以提高性能。确保您编写的doHead方法既安全又幂等(也就是说,保护自己不被一个HTTP头请求多次调用)。
如果HTTP头请求的格式不正确,doHead将返回HTTP“错误请求”消息。

代码示例

代码示例来源:origin: javax.servlet/servlet-api

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: yacy/yacy_grid_mcp

@Override
protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  super.doHead(request, response);
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-servlet_3.0_spec

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: org.jboss.spec.javax.servlet/jboss-servlet-api_3.0_spec

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: in-the-keyhole/khs-sherpa

@Override
protected void doHead(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
  super.doHead(req, resp);
}

代码示例来源:origin: errai/errai

@Override
protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 super.doHead(req, resp);
}

代码示例来源:origin: org.jboss.as/jboss-as-websockets

@Override
protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 super.doHead(req, resp);
}

代码示例来源:origin: mikebrock/jboss-websockets

@Override
protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 super.doHead(req, resp);
}

代码示例来源:origin: net.anotheria/ano-web

@Override
protected void doHead(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  log.debug("doHead Called: "+req.getPathInfo());
  System.out.println("doHead Called: "+req.getPathInfo());
  super.doHead(req, res);
}

代码示例来源:origin: com.helger/ph-webscopes

/**
 * Implement HTTP HEAD
 *
 * @param aHttpRequest
 *        The original HTTP request. Never <code>null</code>.
 * @param aHttpResponse
 *        The original HTTP response. Never <code>null</code>.
 * @param aRequestScope
 *        The request scope to be used. Never <code>null</code>.
 * @throws ServletException
 *         In case of an error.
 * @throws IOException
 *         In case of an error.
 */
@OverrideOnDemand
protected void onHead (@Nonnull final HttpServletRequest aHttpRequest,
            @Nonnull final HttpServletResponse aHttpResponse,
            @Nonnull final IRequestWebScope aRequestScope) throws ServletException, IOException
{
 super.doHead (aHttpRequest, aHttpResponse);
}

代码示例来源:origin: org.jvnet.hudson.winstone/winstone

if (!response.containsHeader(HEADER_LASTMOD) && (lastModified >= 0))
    response.setDateHeader(HEADER_LASTMOD, lastModified);
  doHead(request, response);
} else if (method.equals(METHOD_POST))
  doPost(request, response);

代码示例来源:origin: com.caucho/javaee-16

if (lastModified <= 0) {
 if (isHead)
  doHead(req, res);
 else
  doGet(req, res);
res.setDateHeader("Last-Modified", lastModified);
if (isHead)
 doHead(req, res);
else
 doGet(req, res);

代码示例来源:origin: org.apache.openejb/javaee-api

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: javax/javaee-web-api

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: jakarta.servlet/jakarta.servlet-api

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: org.apache.geronimo.specs/geronimo-servlet_2.5_spec

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: javaee/grizzly

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: javaee/grizzly

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

代码示例来源:origin: org.jboss.spec.javax.servlet/jboss-servlet-api_4.0_spec

long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);

相关文章