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); + } }