HTTP Patch option should be deprecated as the option is doing partial
changes to an existing resource.

combination of the options and trace methods works very well rather than
the Http PATCH

It works very well when the jsperror page is redirected as it shown trace
option


private String getCachedAllowHeaderValue() {
        if (cachedAllowHeaderValue == null) {
            synchronized (cachedAllowHeaderValueLock) {
                if (cachedAllowHeaderValue == null) {

                    Method[] methods =
getAllDeclaredMethods(this.getClass());

                    // RFC 7230 does not define an order for this header
                    // This code aims to retain, broadly, the order of
method
                    // tokens returned in earlier versions of this code. If
that
                    // constraint is dropped then the code can be simplified
                    // further.

                    boolean allowGet = false;
                    boolean allowHead = false;
                    boolean allowPatch = false;
                    boolean allowPost = false;
                    boolean allowPut = false;
                    boolean allowDelete = false;

                    for (Method method : methods) {
                        switch (method.getName()) {
                            case "doGet": {
                                allowGet = true;
                                allowHead = true;
                                break;
                            }
                            case "doPatch": {
                                allowPatch = true;
                                break;
                            }
                            case "doPost": {
                                allowPost = true;
                                break;
                            }
                            case "doPut": {
                                allowPut = true;
                                break;
                            }
                            case "doDelete": {
                                allowDelete = true;
                                break;
                            }
                            default:
                                // NO-OP
                        }

                    }

                    StringBuilder allow = new StringBuilder();

                    if (allowGet) {
                        allow.append(METHOD_GET);
                        allow.append(", ");
                    }

                    if (allowHead) {
                        allow.append(METHOD_HEAD);
                        allow.append(", ");
                    }

                    if (allowPatch) {
                        allow.append(METHOD_PATCH);
                        allow.append(", ");
                    }

                    if (allowPost) {
                        allow.append(METHOD_POST);
                        allow.append(", ");
                    }

                    if (allowPut) {
                        allow.append(METHOD_PUT);
                        allow.append(", ");
                    }

                    if (allowDelete) {
                        allow.append(METHOD_DELETE);
                        allow.append(", ");
                    }

                    // Options is always allowed
                    allow.append(METHOD_OPTIONS);

                    cachedAllowHeaderValue = allow.toString();
                }
            }
        }

        return cachedAllowHeaderValue;
    }

Reply via email to