From 9446cff68dcbd7045a4876779a704c5a05b04083 Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 26 Sep 2024 09:44:40 +0900 Subject: [PATCH] =?UTF-8?q?restricted=20header=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/MainApplication.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/cokr/xit/fims/MainApplication.java b/src/main/java/cokr/xit/fims/MainApplication.java index 7d6c4376..56ec2d05 100644 --- a/src/main/java/cokr/xit/fims/MainApplication.java +++ b/src/main/java/cokr/xit/fims/MainApplication.java @@ -3,6 +3,8 @@ package cokr.xit.fims; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.List; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @@ -18,6 +20,8 @@ public class MainApplication extends SpringBootApplicationBridge { public static void main(String[] args) { + allowRestrictedHeaders(); + try { BufferedReader in = new BufferedReader(new InputStreamReader(new ClassPathResource("sgg.txt").getInputStream())); String sgg = in.readLine(); @@ -29,4 +33,24 @@ public class MainApplication extends SpringBootApplicationBridge { SpringApplication.run(MainApplication.class, args); } + + public static void allowRestrictedHeaders() { + String allowRestrictedHeaders = System.getProperty("jdk.httpclient.allowRestrictedHeaders"); + if(allowRestrictedHeaders == null) { + allowRestrictedHeaders = ""; + } + List allowRestrictedHeadersArr = Arrays.asList(allowRestrictedHeaders.split(",")); + + String[] items = {"connection","host","content-length","expect","upgrade"}; + + for(String item : items) { + if(!allowRestrictedHeadersArr.contains(item)) { + if(!allowRestrictedHeaders.equals("")) { + allowRestrictedHeaders += ","; + } + allowRestrictedHeaders += item; + } + } + System.setProperty("jdk.httpclient.allowRestrictedHeaders", allowRestrictedHeaders); + } }