System.setProperty("sun.net.http.allowRestrictedHeaders","true")在jenkins中不起作用

Rav*_*ean 5 header system request jenkins

我试图在http请求标头中发送原始标头,但是当我得到它的值时,我得到的是null而不是我在origin头中设置的url.

此外,我已通过使用以下内容启用受限标头作为jenkins作业中请求标头的一部分发送

System.setProperty("sun.net.http.allowRestrictedHeaders", "true")
Run Code Online (Sandbox Code Playgroud)

但似乎这个命令不起作用.

Han*_*ank 4

我遇到了同样的问题,对我有用的是在 Surefire-plugin 配置中设置系统参数pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <systemPropertyVariables>
                    <sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
                </systemPropertyVariables>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)