From 6762f0f9ba061747129a39491df8f8683d485955 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 30 Apr 2020 17:13:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E4=B9=9F=E4=B8=8D=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=86=E4=B8=AA=E5=95=A5=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yutou/controller/test.java | 40 +++++++++++++++++++- src/main/java/com/yutou/utlis/Tools.java | 8 +++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yutou/controller/test.java b/src/main/java/com/yutou/controller/test.java index ef63acc..269a714 100644 --- a/src/main/java/com/yutou/controller/test.java +++ b/src/main/java/com/yutou/controller/test.java @@ -1,7 +1,13 @@ package com.yutou.controller; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Base64; import java.util.Date; +import java.util.Enumeration; import java.util.List; +import java.util.zip.GZIPInputStream; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -9,6 +15,7 @@ import javax.servlet.http.HttpServletRequest; import com.yutou.jianrdb.Mapper.MapNodeService; import com.yutou.maptop.Bean.UserTeam; import com.yutou.maptop.services.UserTeamService; +import com.yutou.utlis.Tools; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -50,5 +57,36 @@ public class test { value=RedisUtlis.get(key); return value; } - + @RequestMapping("/cookie/get.do") + @ResponseBody + public String cookies(HttpServletRequest request){ + String cookie=Tools.getCookie(request,null); + Enumeration names=request.getHeaderNames(); + String header=""; + while (names.hasMoreElements()){ + String name=names.nextElement(); + header+=name+":"+request.getHeader(name)+"\n"; + } + System.out.println(cookie); + System.out.println(header); + return cookie; + } + + public static void main(String[] args) { + String data="qobgbw9QQxWj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fdnO9meysj9mfaJbl++BtMR/neo2vbEN8SRj7PkJvMRnXnrmFHYDkZzXrKvkNL9TP7YcIfi9OpKYfOpf+QoWh11HqOMppHcY7BMWt8PEtr/NqZQ4gYqWqt1jPjlaA08KFhIBRoOwarT4d5ByZZNWbzyJlts9rFVfao/TIK2GNcreggug/7xl5DZppJtMaUUk4VXZ3YTw4AxVlqjcBJuc25oxlQwFgM5qq7t6DFkeEmJik1W1Vw2MvRtAJmYoe+gKz8AvOo7cYGpkzS3lDw9Tj+iNfKnfNQ+5ETc5ZR5UHEHbiA7YS7Hqblq4fz+lVozo2n3OL93BnffYSqPbrYuiYPDgelWdTVGLZwAj1kr+cgcU5/g=="; + byte[] bytes=Base64.getDecoder().decode(data); + try { + GZIPInputStream inputStream=new GZIPInputStream(new ByteArrayInputStream(bytes)); + int len=0; + byte bs[]=new byte[1024]; + ByteArrayOutputStream outputStream=new ByteArrayOutputStream(); + while ((len=inputStream.read(bs))!=-1){ + outputStream.write(bs,0,len); + outputStream.flush(); + } + System.out.println(new java.lang.String(bs)); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/yutou/utlis/Tools.java b/src/main/java/com/yutou/utlis/Tools.java index b8772f2..240354b 100644 --- a/src/main/java/com/yutou/utlis/Tools.java +++ b/src/main/java/com/yutou/utlis/Tools.java @@ -14,6 +14,7 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson.JSON; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.web.multipart.MultipartFile; @@ -220,9 +221,14 @@ public class Tools { Cookie[] cookies = request.getCookies(); String value=null; for (Cookie cookie : cookies) { - if (cookie.getName().equals(key)) { + if (key!=null&&cookie.getName().equals(key)) { value=cookie.getValue(); break; + }else if(key==null){ + if(value==null){ + value=""; + } + value+= JSON.toJSONString(cookie); } } return value;