Commit e3a650f8 authored by zengtianlai3's avatar zengtianlai3

解决不安全的http方法

parent cf7965c5
......@@ -31,7 +31,7 @@ import java.util.Map;
*/
@Slf4j
@RestController
@RequestMapping("/")
@RequestMapping("/iot_license")
@Api(value = "登录模块", tags = {"登录模块"})
public class LoginController {
......
......@@ -19,7 +19,7 @@ import java.io.IOException;
@RestController
@RequestMapping("/resource")
@RequestMapping("/iot_license/resource")
@Api(value = "资源模块", tags = {"资源模块"})
public class ResourceContrller {
......
......@@ -11,6 +11,7 @@ import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.Map;
......@@ -35,9 +36,11 @@ public class JwtFilter implements Filter {
final HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
response.setContentType("text/html; charset=utf-8");
if ("OPTIONS".equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
filterChain.doFilter(request, response);
if ("OPTIONS".equals(request.getMethod()) || "HEAD".equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(new String("不安全的请求".getBytes(), StandardCharsets.UTF_8).getBytes());
outputStream.flush();
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment