Why does Spring not support RequestMethod.LINK? How can I catch a query with a LINK method using @RequestMapping or another option?
Asked
Active
Viewed 95 times
0
-
It would be better if you would provide code snippet. Also ask specific question rather than theory. – unknown Feb 10 '19 at 12:17
-
1Never before heard of such a request method, and also the internet standards (https://tools.ietf.org/html/rfc7231, Chapter 4.3 method definitions) don't know anything about it. Where did you hear / read about this new request method? – Thomas Kläger Feb 10 '19 at 12:46
-
@ThomasKläger https://www.w3.org/Protocols/HTTP/Methods/Link.html – Dmitrii Feb 10 '19 at 13:51
-
screenshot Postman - https://prnt.sc/mj4x9z – Dmitrii Feb 10 '19 at 14:10
-
I found an obscure reference to the LINK request method in RFC 2068 (https://tools.ietf.org/html/rfc2068#section-19.6.1.2), dating back to January 1997. RFC 2616 (https://tools.ietf.org/html/rfc2616 from June 1999) obsolotes RFC 2068 and removes the LINK request method. It seems that the LINK request method never got much traction - I doubt you will find any client (except PostMan) that can send this request method. So the question is still: do you need to support this request method? – Thomas Kläger Feb 10 '19 at 15:42
-
Perhaps related: https://stackoverflow.com/questions/12247807/using-link-and-unlink-http-verbs-in-a-rest-api – Roger Lindsjö Feb 10 '19 at 15:51
-
Thanks for the help. I think the question is closed. – Dmitrii Feb 11 '19 at 12:59
1 Answers
0
decision
@RequestMapping("/test")
public int anotherMethods(HttpServletRequest request) {
if (request.getMethod().equals("LINK")) {
logger.info("LINK METHOD");
}
if (request.getMethod().equals("UNLINK")) {
logger.info("UNLINK METHOD");
}
return HttpStatus.OK.value();
}
and add
public class SecurityConfig extends WebSecurityConfigurerAdapter {
...
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
web.httpFirewall(allowHttpMethodsFirewall());
}
@Bean
public HttpFirewall allowHttpMethodsFirewall() {
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowedHttpMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "LINK", "UNLINK"));
return firewall;
}
}

Dmitrii
- 33
- 1
- 8