HtmlUnit இன் ப்ராக்ஸி உள்ளமைவு இடைத்தரகரைத் தேர்ந்தெடுக்கிறது; அதன் சான்று வழங்கி அந்த ஹோஸ்ட் மற்றும் போர்ட்டுக்கான கணக்கை வழங்குகிறது. NTLM ப்ராக்ஸிக்கு, HtmlUnit 4.21.0 API-ல் தனி முறை உள்ளது:

String proxyHost = "proxy.example";
int proxyPort = 8080;
DefaultCredentialsProvider credentials = new DefaultCredentialsProvider();
credentials.addNTLMCredentials(
    user, password.toCharArray(), proxyHost, proxyPort, workstation, domain);

try (WebClient browser = new WebClient()) {
    browser.getOptions().setProxyConfig(
        new ProxyConfig(proxyHost, proxyPort, "http"));
    browser.setCredentialsProvider(credentials);
    HtmlPage page = browser.getPage("https://www.example.com/");
}

இந்த வகுப்புகள் தற்போதைய org.htmlunit தொகுப்புகளைப் பயன்படுத்துகின்றன; HtmlPage org.htmlunit.html-ல் உள்ளது. சூழலுக்கேற்ப ப்ராக்ஸி கணக்கின் workstation மற்றும் domain-ஐ வழங்குங்கள்; இலக்கு இணையதளம் NTLM domain புலம் அல்ல.

பொதுவான username/password சான்றுப் பதிவுக்கு, அதே வழங்கி addCredentials-ஐ வழங்குகிறது; அதில் username, char-array கடவுச்சொல், host, port மற்றும் realm இருக்கும். null realm அந்த எல்லைக்குட்பட்ட endpoint-ல் உள்ள எந்த realm-க்கும் பொருந்தும்.

ப்ராக்ஸியின் அங்கீகார முறைக்கும் உண்மையில் நிறுவப்பட்ட சார்புக்கும் பொருந்தும் overload-ஐப் பயன்படுத்துங்கள். பழைய HtmlUnit 2.x எடுத்துக்காட்டுகள் வேறு தொகுப்புப் பெயர்களைப் பயன்படுத்துகின்றன; string கடவுச்சொல் கையொப்பங்களும் இருக்கலாம்; மேலே உள்ள குறியீடு 4.21.0 API-ஐப் பயன்படுத்துகிறது.

தொடர்புடைய கட்டுரைகள்