I'm writing an HTTP server using the HttpCore library of Apache HTTPComponents 4.3 (Java). My server must be able to receive requests that have non-standard HTTP methods (methods other than GET, POST, DELETE, etc).
But when my server receives such a request, it returns a "method not supported" response. Is there a way to force HTTPComponents to accept non-standard HTTP methods?
Background: I'm working on implementing a WebDAV server, which uses non-standard methods (like MKCOL and PROPFIND).
I found the solution, so I will answer my own question. xD
You have to create your own
HttpRequestFactory
implementation, and pass it up the chain.The implementation that HttpComponents uses by default throws a
MethodNotSupportedException
if a non-standard HTTP method is found. The source code for the default implementation can be found here:http://hc.apache.org/httpcomponents-core-4.3.x/httpcore/xref/org/apache/http/impl/DefaultHttpRequestFactory.html