简体   繁体   English

HTTP DELETE请求产生的状态501未在Google chrome和firefox中实现

[英]HTTP DELETE request produces status 501 not implemented in google chrome and firefox

I am building an application in angular js with REST api. 我正在使用REST API在angular js中构建应用程序。 When I emit this REST DELETE request 当我发出此REST DELETE请求时

DELETE http://localhost:8080/api/users/testlogin HTTP/1.1
Host: localhost:8080
Proxy-Connection: keep-alive
Accept: application/json, text/plain, */*
Origin: http://localhost:8080
X-CSRF-TOKEN: 0baaf5bf-b3bf-4a9b-a770-2ab3f50d153b
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
DNT: 1
Referer: http://localhost:8080/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: JSESSIONID=64D42E7FC0969F7F3960219309EFD0A4; remember-me=VDNpbGxmWC96clJESmNqU0d1bE0rUT09OkFHMFNxTnltRk5xMXVXVHNHRXFkNEE9PQ; CSRF-TOKEN=0baaf5bf-b3bf-4a9b-a770-2ab3f50d153b; NG_TRANSLATE_LANG_KEY=%22en%22

I get on Google chrome Version 49.0.2623.112 m (64-bit) and Firefox Developer Edition 47.0a2 (2016-04-12), the response 我在Google chrome版本49.0.2623.112 m(64位)和Firefox开发人员版47.0a2(2016-04-12)上获得响应

Request URL: http://localhost:8080/api/users/testlogin
Request Method: DELETE
Status Code: 501 Not Implemented
Remote Address:127.0.0.1:9614

The weird part is the same operation succeeded in IE 11. The request above works too when using Advanced REST client chrome app (it produces status 200 and it does what it's supposed to do :) ). 奇怪的部分是在IE 11中成功完成的同一操作。使用Advanced REST客户端chrome应用程序时,上面的请求也起作用(它的状态为200,并且它应该执行的操作:))。

In IE, the request contains 在IE中,请求包含

Request DELETE /api/users/testlogin HTTP/1.1
X-CSRF-TOKEN    d112e1f0-2b04-47a1-a8fb-4873c769ab2f
Accept  application/json, text/plain, */*
Referer http://127.0.0.1:8080/
Accept-Language fr-FR
Accept-Encoding gzip, deflate
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host    127.0.0.1:8080
Content-Length  0
Connection  Keep-Alive
Cache-Control   no-cache
Cookie  remember-me=RGxLZ20vQXcrNVZEVXFFMVNyN2p3dz09OmRTNEtwZWErTitHRjg1MEJNTENXbUE9PQ; JSESSIONID=96484DEDF9D04D275DE43ADB186572C6; CSRF-TOKEN=d112e1f0-2b04-47a1-a8fb-4873c769ab2f; NG_TRANSLATE_LANG_KEY=%22fr%22

Code that performs Delete (angularjs v1.4.8) : 执行Delete(angularjs v1.4.8)的代码:
Controller: 控制器:

angular.module('myApp')
.controller('UserDeleteController', function($scope, $uibModalInstance, entity, User) {

    $scope.user = entity;
    $scope.clear = function() {
        $uibModalInstance.dismiss('cancel');
    };
    $scope.confirmDelete = function (login) {
        User.delete({login: login},
            function () {
                $uibModalInstance.close(true);
            });
    };
});

Resource: 资源:

angular.module('myApp')
.factory('User', function ($resource) {
    return $resource('api/users/:login', {}, {
        'query': {method: 'GET', isArray: true},
        'get': {
            method: 'GET',
            transformResponse: function (data) {
                data = angular.fromJson(data);
                return data;
            }
        },
        'save': { method:'POST' },
        'update': { method:'PUT' },
        'delete':{ method:'DELETE'}
    });
})

Any idea why this behavior ?? 任何想法为什么这种行为??

Solved by invalidating intellij cache and clearing browser cache too. 通过使intellij缓存无效并清除浏览器缓存来解决。 Guess I'll need to add a cache buster in prod :). 猜猜我需要在prod中添加一个缓存破坏器:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM