java - Browser sends OPTIONS instead of PUT or DELETE -
i'm using gwt restlet , want send delete restserver. client code sending:
private void recipedeletebutton() { string id = views.getviewrecipedetail().getrecipeid().gettext(); clientresource res = new clientresource(rest.recipe_client_resource_local + id); res.setonresponse(new uniform() { @override public void handle(request request, response response) { system.out.println(response.getstatus().getdescription()); } }); res.delete(); }
but when want test firefox says:
[22:28:28.796] options http://localhost:8182/recipe/35 [http/1.1 405 method not allowed 3ms]
i have found post here: browsers send options instead of post after changing http header not solve problem. post , works firefox addon resolve problem sop, there possiblity add new headers, adding put,delete , options not resolve problem..
does know solution this, in advance
edit
i have tried on serverside, still comes 405.
series<header> responseheaders = (series<header>) getresponse().getattributes().get("org.restlet.http.headers"); if (responseheaders == null) { responseheaders = new series<header>(header.class); responseheaders.add(new header("access-control-allow-origin", "*")); responseheaders.add(new header("access-control-allow-methods", "get,post,put,delete,options")); getresponse().getattributes().put("org.restlet.http.headers", responseheaders); }
sending option request expected behavior in case of cors request. can add handler options in restserver.
you need return valid access-control-allow-origin , access-control-allow-methods. client send second request (put or delete in case).
Comments
Post a Comment