Restlet-ന്റെ ClientResource നിങ്ങൾ കോൺഫിഗർ ചെയ്ത proxy connector ഉപയോഗിക്കാൻ ഉണ്ടാക്കുക
Restlet 2.4.4-ന്റെ Apache HTTP client helper-നായി, സ്റ്റാർട്ട് ചെയ്യുന്നതിന് മുൻപ് connector context parameters സെറ്റ് ചെയ്ത് setNext ഉപയോഗിച്ച് അറ്റാച്ച് ചെയ്യുക.
കോൺഫിഗർ ചെയ്ത Client, മറ്റൊരു connector ഉപയോഗിക്കുന്ന ClientResource-ൽ ഫലം ഉണ്ടാക്കുന്നില്ല. Restlet 2.4.4-ന്റെ org.restlet.ext.httpclient helper-നായി, സ്റ്റാർട്ട് ചെയ്യുന്നതിന് മുൻപ് resource-നെ ആ client-ലേക്ക് ബന്ധിപ്പിക്കുക:
Client connector = new Client(new Context(), Protocol.HTTPS);
connector.getContext().getParameters().set("proxyHost", "proxy.example");
connector.getContext().getParameters().set("proxyPort", "8080");
ClientResource resource = new ClientResource(
"https://service.example/status");
resource.setNext(connector);
connector.start();
try {
String body = resource.get().getText();
} finally {
resource.release();
connector.stop();
}setNext(connector) ആണ് അറ്റാച്ച്മെന്റ് പോയിന്റ്. helper-ന്റെ ഡോക്യുമെന്റ് ചെയ്ത proxyHost, proxyPort കീകൾ context ഉപയോഗിക്കുന്നു; hostname അതിന്റെ scheme-ൽ നിന്നും port-ൽ നിന്നും വേർതിരിച്ചിരിക്കുന്നു. connector.start()-ന് മുൻപ് അവ സെറ്റ് ചെയ്യുക. പൊതു HTTP endpoint-ന്, ഈ രണ്ട് ഫീൽഡുകളും HTTP proxy list-ൽ നിന്ന് ഒരു വിലാസവും port-ഉം എടുക്കുന്നു.
വിന്യസിച്ച helper പറഞ്ഞ Apache extension ആണെന്ന് ഇത് അനുമാനിക്കുന്നു. JVM http.proxyHost, http.proxyPort എന്നിവയിൽ നിന്ന് ഇതിന് സ്വതേയുള്ള മൂല്യങ്ങളും ലഭിക്കാം; വ്യക്തമായ context മൂല്യങ്ങൾ ഈ connector-ന്റെ endpoint ദൃശ്യമാക്കുന്നു.
ഉദാഹരണം text body ഉപയോഗിച്ച് തീർക്കുന്നു, resource റിലീസ് ചെയ്ത് connector നിർത്തുന്നു. streaming ഉപയോഗവും അതിന്റെ representation ഉപയോഗിക്കുകയോ റിലീസ് ചെയ്യുകയോ ചെയ്യണം, അങ്ങനെ pooled connections റിലീസ് ചെയ്യാനാകും.