Implements a OPTIONS HTTP method function returning all allowed HTTP
        methods.
180085
def options(self, request, *args, **kwargs):
        
        allow = []
        for method in self.http_method_names:
            if hasattr(self, method):
                allow.append(method.upper())
        r = self.render_to_response(None)
        r['Allow'] = ','.join(allow)
        return r
1161668
private static Function<Service<HttpRequest, HttpResponse>,
            ? extends Service<HttpRequest, HttpResponse>> decorator(
            Method method, Class<?> clazz,
            Function<Service<HttpRequest, HttpResponse>,
                    ? extends Service<HttpRequest, HttpResponse>> initialDecorator) {

        final List<DecoratorAndOrder> decorators = collectDecorators(clazz, method);

        Function<Service<HttpRequest, HttpResponse>,
                ? extends Service<HttpRequest, HttpResponse>> decorator = initialDecorator;
        for (int i = decorators.size() - 1; i >= 0; i--) {
            final DecoratorAndOrder d = decorators.get(i);
            decorator = decorator.andThen(d.decorator());
        }
        return decorator;
    }
891907
public function allowedHttpVerbs() : array
    {
        return [
            HttpRequest::METHOD_GET,
            HttpRequest::METHOD_POST,
            HttpRequest::METHOD_PATCH,
            HttpRequest::METHOD_DELETE,
            HttpRequest::METHOD_HEAD,
            HttpRequest::METHOD_OPTIONS,
        ];
    }
418414
function isRemoteMethodAllowed(method, allowedVerbs) {

    let httpArray = method.http;

    if (!_.isArray(method.http)) {
        httpArray = [method.http];
    }

    const results = httpArray.map((item) => {

        const verb = item.verb;

        if (allowedVerbs && !_.includes(allowedVerbs, verb)) {
            return false;
        }

        return true;
    });

    const result = _.includes(results, true);

    return result;
}
992084
def get_http_method(self, method):
        """"""
        return self.http_methods[method](self.url, **self.http_method_args)
317547
public B allowRequestMethods(HttpMethod... methods) {
        requireNonNull(methods, "methods");
        checkArgument(methods.length > 0, "methods should not be empty.");
        for (int i = 0; i < methods.length; i++) {
            if (methods[i] == null) {
                throw new NullPointerException("methods[" + i + ']');
            }
        }
        Collections.addAll(allowedRequestMethods, methods);
        return self();
    }
332361
def _http(method, url, headers=None, **kw):
    '''
    
    '''
    params = None
    boundary = None
    if method == 'UPLOAD':
        params, boundary = _encode_multipart(**kw)
    else:
        params = _encode_params(**kw)
    http_url = '%s?%s' % (url, params) if method == _HTTP_GET else url
    http_body = None if method == 'GET' else params
    logging.error('%s: %s' % (method, http_url))
    req = urllib2.Request(http_url, data=http_body)
    req.add_header('Accept-Encoding', 'gzip')
    if headers:
        for k, v in headers.iteritems():
            req.add_header(k, v)
    if boundary:
        req.add_header('Content-Type', 'multipart/form-data; boundary=%s' % boundary)
    try:
        resp = urllib2.urlopen(req, timeout=5)
        return _read_http_body(resp)
    finally:
        pass
344804
function allowedMethods(methods) {
  // default values
  var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false  };
  // check and override if one of the default methods
  for (var key in methods) {
    var newKey = key.toUpperCase();
    if ( methodsAllowed[newKey]!=undefined) {
      methodsAllowed[newKey] = Boolean(methods[key]);
    }
  }
  return methodsAllowed;
}
60184
def hijack_require_http_methods(fn):
    
    required_methods = ['POST']
    if hijack_settings.HIJACK_ALLOW_GET_REQUESTS:
        required_methods.append('GET')
    return require_http_methods(required_methods)(fn)
78097
def require_http_methods(request_methods):
    
    if not isinstance(request_methods, (list, tuple)):
        raise ImproperlyConfigured(
            "require_http_methods decorator must be called "
            "with a list or tuple of strings. For example:\n\n"
            "    @require_http_methods(['GET', 'POST'])\n"
            "    def function_view(request):\n"
            "        ...\n")

    request_methods = list(map(str.upper, request_methods))

    for method in request_methods:
        if method not in HTTP_METHOD_NAMES:
            raise ImproperlyConfigured(
                "require_http_method called with '%s', "
                "which is not a valid HTTP method.\n"
                % (method,))

    if 'GET' in request_methods and 'HEAD' not in request_methods:
        request_methods.append('HEAD')
    if 'OPTIONS' not in request_methods:
        request_methods.append('OPTIONS')
    request_methods.sort()

    def decorator(func):
        @wraps(func, assigned=available_attrs(func))
        def inner(request, *args, **kwargs):
            if request.method == 'OPTIONS':
                response = HttpResponse()
                response['Allow'] = ', '.join(
                    [m.upper() for m in request_methods])
                response['Content-Length'] = '0'
                return response
            if request.method not in request_methods:
                logger.warning(
                    'Method Not Allowed (%s): %s',
                    request.method,
                    request.path,
                    extra={
                        'status_code': 405,
                        'request': request
                    }
                )
                return HttpResponseNotAllowed(request_methods)
            return func(request, *args, **kwargs)
        return inner
    return decorator
147658
def allowed_methods(self):
        
        return [
            method
            for method, allowed in (
                ('GET', hasattr(self, 'on_get')),
                ('POST', hasattr(self, 'on_post')),
                ('PUT', hasattr(self, 'on_put')),
                ('PATCH', hasattr(self, 'on_patch')),
                ('DELETE', hasattr(self, 'on_delete')),
                ('HEAD', hasattr(self, 'on_head')),
                ('OPTIONS', hasattr(self, 'on_options')),
            ) if allowed
        ]
91481
function http(url, options) {
  return request(url, extend({}, this.options.http, options))
    .then(function(response) {
      if (!response.ok) throw response.status + '' + response.statusText;
      return response.text();
    });
}
1004999
private static HttpUriRequest createHttpUriRequest(String method, URI uri) {
        switch (method) {
            case "GET":
                return new HttpGet(uri);
            case "HEAD":
                return new HttpHead(uri);
            case "POST":
                return new HttpPost(uri);
            case "PUT":
                return new HttpPut(uri);
            case "PATCH":
                return new HttpPatch(uri);
            case "DELETE":
                return new HttpDelete(uri);
            case "OPTIONS":
                return new HttpOptions(uri);
            case "TRACE":
                return new HttpTrace(uri);
            default:
                throw new IllegalArgumentException("Invalid HTTP method: " + method);
        }
    }
943598
def get_options(server):
    """"""
    try:
        response = requests.options(
            server, allow_redirects=False, verify=False, timeout=5)
    except (requests.exceptions.ConnectionError,
            requests.exceptions.MissingSchema):
        return "Server {} is not available!".format(server)

    try:
        return {'allowed': response.headers['Allow']}
    except KeyError:
        return "Unable to get HTTP methods"
671546
public function getImplementedMethods() {

        $supported_methods = $this->getConfiguration()->get('supported-http-methods');

        if ( is_null($supported_methods) ) $supported_methods = self::$supported_methods;

        if ( method_exists($this, 'any') ) {

            return $supported_methods;

        }

        $implemented_methods = [];

        foreach ( $supported_methods as $method ) {

            if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods, $method);

        }

        return $implemented_methods;

    }
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;
    }
22074
def _guess_available_methods(self):
        
        available_methods = []
        for m in ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]:
            self_method = getattr(type(self), "API_{}".format(m))
            super_method = getattr(APIPage, "API_{}".format(m))
            if self_method != super_method:
                available_methods.append(m)
        return available_methods