[
https://issues.apache.org/jira/browse/OLINGO-840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15064606#comment-15064606
]
Michael Bolz commented on OLINGO-840:
-------------------------------------
As workaround a service could use a *Java Servlet Filter* to respond to
{{HEAD}} requests before it is passed to (processed by) Olingo.
Sample servlet filter class:
{code}
package org.apache.olingo.odata2.ref;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
*/
public class HeadServletFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException { }
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
if(!httpRequest.getMethod().equalsIgnoreCase("HEAD")){
filterChain.doFilter(request, response);
}
}
@Override
public void destroy() { }
}
{code}
Sample snippet for {{web.xml}}:
{code}
<filter>
<filter-name>RequestLoggingFilter</filter-name>
<filter-class>org.apache.olingo.odata2.ref.HeadServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RequestLoggingFilter</filter-name>
<url-pattern>/*</url-pattern>
<servlet-name>ReferenceScenarioNonJaxrsServlet</servlet-name>
</filter-mapping>
{code}
> HTTP HEAD method request results in 501 - Not Implemented
> ---------------------------------------------------------
>
> Key: OLINGO-840
> URL: https://issues.apache.org/jira/browse/OLINGO-840
> Project: Olingo
> Issue Type: Bug
> Components: odata2-core
> Affects Versions: V2 2.0.5
> Reporter: Michael Bolz
> Assignee: Michael Bolz
> Priority: Minor
>
> A {{HTTP HEAD}} method request results in {{501 - Not Implemented}}.
> According to OData V2 specification section *2.2.4 HTTP Methods*:
> {quote}
> ...All additional HTTP methods used by this document are specified in
> [RFC2616]...
> {quote}
> and [RFC 2616|https://tools.ietf.org/html/rfc2616] (refer to newer [RFC
> 7230|https://tools.ietf.org/html/rfc7230] and
> [7231|https://tools.ietf.org/html/rfc7231])
> in section [7231: Section-4.1|https://tools.ietf.org/html/rfc7231#section-4.1]
> {quote}
> ...
> All general-purpose servers MUST support the methods GET and HEAD.
> All other methods are OPTIONAL.
> ...
> {quote}
> a {{HEAD}} request must not lead to a {{501 - Not implemented}}.
> {quote}
> +---------+-------------------------------------------------+-------+
> | Method | Description | Sec. |
> +---------+-------------------------------------------------+-------+
> | GET | Transfer a current representation of the target | 4.3.1 |
> | | resource. | |
> | HEAD | Same as GET, but only transfer the status line | 4.3.2 |
> | | and header section. | |
> | POST | Perform resource-specific processing on the | 4.3.3 |
> | | request payload. | |
> | PUT | Replace all current representations of the | 4.3.4 |
> | | target resource with the request payload. | |
> | DELETE | Remove all current representations of the | 4.3.5 |
> | | target resource. | |
> | CONNECT | Establish a tunnel to the server identified by | 4.3.6 |
> | | the target resource. | |
> | OPTIONS | Describe the communication options for the | 4.3.7 |
> | | target resource. | |
> | TRACE | Perform a message loop-back test along the path | 4.3.8 |
> | | to the target resource. | |
> +---------+-------------------------------------------------+-------+
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)