Allow all allowed methods
964437
def determine_actions(self, request, view):
        """"""
        from rest_framework.generics import GenericAPIView
        actions = {}
        excluded_methods = {'HEAD', 'OPTIONS', 'PATCH', 'DELETE'}
        for method in set(view.allowed_methods) - excluded_methods:
            view.request = clone_request(request, method)
            try:
                if isinstance(view, GenericAPIView):
                    has_object = view.lookup_url_kwarg or view.lookup_field in view.kwargs
                elif method in {'PUT', 'POST'}:
                    has_object = method in {'PUT'}
                else:
                    continue
                # Test global permissions
                if hasattr(view, 'check_permissions'):
                    view.check_permissions(view.request)
                # Test object permissions
                if has_object and hasattr(view, 'get_object'):
                    view.get_object()
            except (exceptions.APIException, PermissionDenied, Http404):
                pass
            else:
                # If user has appropriate permissions for the view, include
                # appropriate metadata about the fields that should be supplied.
                serializer = view.get_serializer()
                actions[method] = self.get_serializer_info(serializer)
            finally:
                view.request = request

        return actions
453306
public function setAllowedHttpMethods(array $allowedHttpMethods = null)
    {
        $results = null;
        if (is_array($allowedHttpMethods)) {
            $results = array_map(function ($method) {
                $method = trim($method);
                $method = strtolower($method);

                return $method;
            }, $allowedHttpMethods);

            $results = array_combine($results, $results);
        }
        $this->allowedHttpMethods = $results;

        return $this;
    }
276005
public function options()
    {
        if (!($this->response instanceof ResponseInterface)) {
            throw new MethodNotAllowed();
        }

        // Get all implemented methods for this resources
        $methods = get_class_methods(get_class($this));

        // Get supported verbs
        $validMethods = $this->container['validHttpVerbs'];

        // Loop though class functions/methods
        foreach ($methods as $key => &$method) {
            $method = strtoupper($method);
            // If class function/method isn't a verb, then unset it
            if (!in_array($method, $validMethods)) {
                unset($methods[$key]);
            }
        }

        // Set accept header
        $this->response = $this->response->withAddedHeader('Allow', implode(', ', $methods));

        // Prepare output
        $output = [];
        $output['Content-Type'] = $this->container['contentTypes'];
        $output['Accept'] = $this->container['acceptTypes'];

        foreach ($methods as $verb) {
            $doc = $this->parseMethodDoc($verb);

            // Check if there is any output to show
            if (!empty($doc)) {
                $output['methods'][$verb] = $doc;
            }
        }

        // return output
        return $output;
    }
796797
def enabled_checker(func):
        
        @wraps(func)
        def wrap(self, *args, **kwargs):
            if self.allowed_methods and isinstance(self.allowed_methods, list) and func.__name__ not in self.allowed_methods:
                raise Exception("Method {} is disabled".format(func.__name__))
            return func(self, *args, **kwargs)
        return wrap
852894
public function allowMethods($methods = '*')
    {
        $this->response = $this->corsHandler->setResponse($this->response)
            ->allowMethods($methods)
            ->getResponse();

        return $this;
    }
379095
private synchronized static void allowPatchRequestsIfNeeded() throws GeneralException {
        if (isPatchRequestAllowed) {
            // Don't do anything if we've run this method before. We're in a
            // synchronized block, so return ASAP.
            return;
        }

        try {
            // Ensure we can access the fields we need to set.
            Field methodsField = HttpURLConnection.class.getDeclaredField("methods");
            methodsField.setAccessible(true);

            Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL);

            Object noInstanceBecauseStaticField = null;

            // Determine what methods should be allowed.
            String[] existingMethods = (String[]) methodsField.get(noInstanceBecauseStaticField);
            String[] allowedMethods = getAllowedMethods(existingMethods);

            // Override the actual field to allow PATCH.
            methodsField.set(noInstanceBecauseStaticField, allowedMethods);

            // Set flag so we only have to run this once.
            isPatchRequestAllowed = true;
        } catch (IllegalAccessException | NoSuchFieldException e) {
            throw new GeneralException(CAN_NOT_ALLOW_PATCH);
        }
    }
883237
private Permission permissionForMethod(String method) {
        switch (method.toUpperCase()) {
        case "GET":
            return Permission.READ;
        case "PUT":
        case "DELETE":
            return Permission.UPDATE;
        case "POST":
            return Permission.APPEND;
        default:
            throw new RuntimeException("Unexpected REST method: " + method);
        }
    }
500200
def verify_request_method env
        allowed = ALLOWED_METHODS
        allowed |= ALLOWED_METHODS_PRIVATE if whitelisted?(env)
        if !allowed.include?(env[METHOD])
          raise "Request method #{env[METHOD]} not allowed"
        end
      end
846110
function sendOptionsResponse(res, methods) {
  var options = Object.create(null)

  // build unique method map
  for (var i = 0; i < methods.length; i++) {
    options[methods[i]] = true
  }

  // construct the allow list
  var allow = Object.keys(options).sort().join(', ')

  // send response
  res.setHeader('Allow', allow)
  res.setHeader('Content-Length', Buffer.byteLength(allow))
  res.setHeader('Content-Type', 'text/plain')
  res.setHeader('X-Content-Type-Options', 'nosniff')
  res.end(allow)
}
26820
def custom_allow?(feature)
      allow? &&
        !custom_config(feature).empty? &&
        build_acls(custom_config(feature).fetch(:acls, []).map(&:to_h)).all?(&:allow?)
    end
326492
def process_allow_action(processors, action, argument):
    """"""
    for processor in processors:
        processor(action, argument)
    db.session.commit()
331688
def _add_numeric_methods_disabled(cls):
        
        cls.__pow__ = make_invalid_op('__pow__')
        cls.__rpow__ = make_invalid_op('__rpow__')
        cls.__mul__ = make_invalid_op('__mul__')
        cls.__rmul__ = make_invalid_op('__rmul__')
        cls.__floordiv__ = make_invalid_op('__floordiv__')
        cls.__rfloordiv__ = make_invalid_op('__rfloordiv__')
        cls.__truediv__ = make_invalid_op('__truediv__')
        cls.__rtruediv__ = make_invalid_op('__rtruediv__')
        cls.__mod__ = make_invalid_op('__mod__')
        cls.__divmod__ = make_invalid_op('__divmod__')
        cls.__neg__ = make_invalid_op('__neg__')
        cls.__pos__ = make_invalid_op('__pos__')
        cls.__abs__ = make_invalid_op('__abs__')
        cls.__inv__ = make_invalid_op('__inv__')
777951
public void setAllowedMethods(RequestTypeEnum... theAllowedMethods) {
		if (theAllowedMethods == null || theAllowedMethods.length == 0) {
			myAllowedMethods = null;
		} else {
			myAllowedMethods = new LinkedHashSet<RequestTypeEnum>();
			for (RequestTypeEnum next : theAllowedMethods) {
				myAllowedMethods.add(next);
			}
		}
		updateAllowHeader();
	}
130872
def can_not(*args)
      args.last.is_a?(Hash) ? args.last[:restriction]= true : args << {:restriction => true}
      add_permission(@restrictions, *args)
    end
409799
def destruction_allowed?
      success = protect_if_methods.all? do |method, message|
        allowed = protect_method_allows_destruction(method)
        errors.add(:base, message) if !allowed && message
        allowed
      end

      throw(:abort) if !success && ActiveRecord::VERSION::MAJOR >= 5
      success
    end
1289418
def show_form_for_method(self, view, method, request, obj):
        
        if method not in view.allowed_methods:
            return  # Not a valid method

        try:
            view.check_permissions(request)
            if obj is not None:
                view.check_object_permissions(request, obj)
        except exceptions.APIException:
            return False  # Doesn't have permissions
        return True
1126243
public function methodNotAllowed(string $requestMethod, array $allowedMethods): Error
    {
        $this->status->methodNotAllowed($allowedMethods);
        return Error::methodNotAllowed($requestMethod, $allowedMethods);
    }