0
非常に特定の要求に対してHostヘッダーを設定する必要がありますが、これは考慮されていません。HttpUrlConnect set Host header
私はこれが制限されたヘッダーだと知っていますが、どうすれば可能ですか?
ここで私は何をしようとしています。
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setConnectTimeout(10000);
urlConnection.setRequestProperty("Host", "test.com");
urlConnection.setRequestMethod("GET");
int responseCode = urlConnection.getResponseCode();
Log.d(TAG, String.format("response code: %d", responseCode));
} catch (IOException e) {
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
の可能性のある重複(http://stackoverflow.com/questions/7648872/can-i-override-the-host -header-where-using-javas-httpurlconnection-class) –
確かに。私は 'System.setProperty(" sun.net.http.allowRestrictedHeaders "、" true ")'を 'Application.onCreate()'にセットしています。 – HelderMPinhal