From e7c269e6badf08a663702111bcf07f20f3de92dc Mon Sep 17 00:00:00 2001 From: yutou Date: Fri, 25 Dec 2020 16:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E/public/request.do=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=8E=B7=E5=8F=96=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/tools/ToolsApplication.java | 2 +- .../java/com/yutou/tools/other/tools.java | 81 +++++++++++-------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index e186cbf..2c35361 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ToolsApplication { - public static final String version="1.0.14"; + public static final String version="1.0.14.1"; public static void main(String[] args) { System.out.println("当前版本号:"+version); diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java index 7c88dde..cce0790 100644 --- a/src/main/java/com/yutou/tools/other/tools.java +++ b/src/main/java/com/yutou/tools/other/tools.java @@ -3,6 +3,8 @@ package com.yutou.tools.other; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yutou.tools.ToolsApplication; +import com.yutou.tools.utils.QQBotManager; +import com.yutou.tools.utils.Tools; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -16,42 +18,22 @@ import java.util.Enumeration; @Controller public class tools { - - @ResponseBody - @RequestMapping(value = "tools/cookie.do",method = RequestMethod.POST) - public String cookieToJson(HttpServletRequest request){ - JSONObject json=new JSONObject(); - JSONArray array=new JSONArray(); - for (Cookie cookie : request.getCookies()) { - JSONObject item=new JSONObject(); - item.put("name",cookie.getName()); - item.put("value",cookie.getValue()); - item.put("domain",cookie.getDomain()); - item.put("path",cookie.getPath()); - item.put("maxAge",cookie.getMaxAge()); - item.put("secure",cookie.getSecure()); - item.put("isHttpOnly",cookie.isHttpOnly()); - array.add(item); - } - json.put("data",array); - return json.toJSONString(); - } @ResponseBody @RequestMapping(value = "tools/get.do") public String getJs(HttpServletRequest request, HttpServletResponse response) throws Exception { - Enumeration name=request.getHeaderNames(); - while (name.hasMoreElements()){ - String na=name.nextElement(); - System.out.println(na+" "+request.getHeader(na)); + Enumeration name = request.getHeaderNames(); + while (name.hasMoreElements()) { + String na = name.nextElement(); + System.out.println(na + " " + request.getHeader(na)); } - File file=new File("D:\\IDEA\\web_toolset\\web\\js\\my.js"); - BufferedReader reader=new BufferedReader(new FileReader(file)); - String tmp,str=""; - while ((tmp=reader.readLine())!=null){ - if(tmp.contains("\"")){ - // tmp=tmp.replace("\"","\\\""); + File file = new File("D:\\IDEA\\web_toolset\\web\\js\\my.js"); + BufferedReader reader = new BufferedReader(new FileReader(file)); + String tmp, str = ""; + while ((tmp = reader.readLine()) != null) { + if (tmp.contains("\"")) { + // tmp=tmp.replace("\"","\\\""); } - str+=tmp; + str += tmp; } reader.close(); /* response.setHeader("Content-Type","application/javascript; charset=utf-8"); @@ -59,12 +41,45 @@ public class tools { writer.write(str); writer.flush(); writer.close();*/ - return str; + return str; //return "function test(){ return \"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588139022200&di=8cc8405f7514dd54bd82fcd070349603&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg\" }"; } + @RequestMapping("/public/version.do") @ResponseBody - public String getVersion(){ + public String getVersion() { return ToolsApplication.version; } + + @ResponseBody + @RequestMapping("/public/request.do") + public String testRequest(HttpServletRequest request) { + JSONObject params = new JSONObject(); + JSONArray cookies = new JSONArray(); + JSONObject header=new JSONObject(); + for (String key : request.getParameterMap().keySet()) { + params.put(key, request.getParameter(key)); + } + if (request.getCookies() != null) { + for (Cookie cookie : request.getCookies()) { + JSONObject ck = JSONObject.parseObject(JSONObject.toJSONString(cookie)); + cookies.add(ck); + } + } + Enumeration enumeration=request.getHeaderNames(); + while (enumeration!=null&&enumeration.hasMoreElements()){ + String tmp= enumeration.nextElement(); + header.put(tmp,request.getHeader(tmp)); + } + JSONObject json = new JSONObject(); + json.put("code", 0); + json.put("address", Tools.getRemoteAddress(request)); + json.put("UA",request.getHeader("")); + json.put("addressUrl", request.getPathInfo()); + json.put("params", params); + json.put("cookie", cookies); + json.put("header",header); + Tools.sendServer("打印请求", json.toJSONString()); + return json.toJSONString(); + } }