Code example for MethodNotSupportedException

0
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
 
            String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH); 
            if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) { 
                throw new MethodNotSupportedException(method + " method not supported");  
            } 
            String target = request.getRequestLine().getUri(); 
 
            if (request instanceof HttpEntityEnclosingRequest) { 
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); 
                byte[] entityContent = EntityUtils.toByteArray(entity); 
                System.out.println("Incoming entity content (bytes): " + entityContent.length); 
            } 
             
            final File file = new File(this.docRoot, URLDecoder.decode(target)); 
            if (!file.exists()) { 
 
                response.setStatusCode(HttpStatus.SC_NOT_FOUND); 
                EntityTemplate body = new EntityTemplate(new ContentProducer() {