Code example for MethodNotSupportedException

0
 
        public void handle(final HttpRequest request, 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 && target.equals("/thrift/service/tutorial/")) {
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                byte[] entityContent = EntityUtils.toByteArray(entity);
                System.out.println("Incoming content: " + new String(entityContent));
                 
                final String output = this.thriftRequest(entityContent);
                 
                System.out.println("Outgoing content: "+output);
                 
                EntityTemplate body = new EntityTemplate(new ContentProducer() {
 
                    public void writeTo(final OutputStream outstream) throws IOException {