Gateway encryption and decryption occasionally HTTP method names must be tokensConnection prematurely closed BEFORE response problem

Uncle Cthulhu 2022-11-24 21:24:38 阅读数:79

gatewayencryptiondecryptionoccasionallyhttp

Background

In the previous blog, RSA and AES were used to complete the encryption and decryption of the interface, but in the actual test process, occasionally there will be problems of `HTTP method names must be tokens`, `Connection prematurely closed BEFORE response`

Previous article: Gateway Interface Parameter Encryption and Decryption_Uncle Cthulhu’s Blog-CSDN Bloghttps://blog.csdn.net/qq_17213067/article/details/127859326

The road to solution

Puzzled, Google and Baidu have been searched, but still can’t solve it, it’s useless to change the size of the request header, for example: SpringBoot: Invalid character found in method">SpringBoot: Invalid character found in methodmethod name. HTTP method names must be tokens_Moshow Zheng Kai's Blog-CSDN Blog_invalid character found in method

Another example: The problem caused by the header parameter Content-length——The understanding of HTTP long connection- Short book (jianshu.com)

Later, by chance, I saw some ideas on deleting the request header in Gateway on stackoverflow, and after trying N times, I found that it was solved.

The solution

Dockerfile

#Dependent base image jdk8FROM openjdk:8u275-slim#The port that needs to be exposed is the port of my project#EXPOSE 8000#author informationMAINTAINER xxxENV TZ GMT+8ENV JAR_NAME nxx.jarADD /target/$JAR_NAME $JAR_NAMEENV JAVA_OPTS -Dname=$JAR_NAME -server -Xmx512m -Xms512m -Xmn256m -Xss256k -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -Duser.timezone=GMT+8# After starting the container, the default run command#ENTRYPOINT java $JAVA_OPTS -jar $JAR_NAME# Solution: Connection prematurely closed BEFORE response, step 1ENTRYPOINT java $JAVA_OPTS -Dreactor.netty.pool.leasingStrategy=lifo -jar $JAR_NAME

bootstrap.xml

spring:cloud:# Solution: Connection prematurely closed BEFORE response, step 2gateway:# Solution: HTTP method names must be tokens I don't know whyfilter:remove-hop-by-hop:headers: Connection

Follow

So far I don’t know why, but it is solved. I hope that the passing master will answer it and give me advice.

版权声明:本文为[Uncle Cthulhu]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/328/202211242120376882.html