As part of my JUnit test suite I have to test sending an HTTP request with one of HttpURLConnection restricted headers.
conn.setRequestProperty("Host", host);
In @BeforeTest I can allow the restricted headers, but that won't work when the class' static initializer is executed beforehand:
@BeforeClass
public static void init() {
// this won't work because HttpURLConnection has already been initialized
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
}
What would be another method of allowing the restricted headers that will work like allowRestrictedHeaders?
Aucun commentaire:
Enregistrer un commentaire