@Override public synchronized void start() throws Exception { super.start(); getLogger().info("Starting the internal HTTP client"); }
@Override public synchronized void stop() throws Exception { super.stop(); getLogger().info("Stopping the HTTP client"); }
@Override public void handle(Request request, Response response) { try { ClientCall clientCall = getAdapter().toSpecific(this, request); getAdapter().commit(clientCall, request, response); } catch (Exception e) { getLogger().log(Level.INFO, "Error while handling an HTTP client call", e); response.setStatus(Status.CONNECTOR_ERROR_INTERNAL, e); } }
/** * Returns the adapter from uniform calls to HTTP calls. * * @return the adapter from uniform calls to HTTP calls. */ public ClientAdapter getAdapter() throws Exception { if (this.adapter == null) { String adapterClass = getHelpedParameters().getFirstValue( "adapter", "org.restlet.engine.adapter.ClientAdapter"); this.adapter = (ClientAdapter) Class.forName(adapterClass) .getConstructor(Context.class).newInstance(getContext()); } return this.adapter; }
/** * Returns the connection timeout. Defaults to 15000. * * @return The connection timeout. */ public int getSocketConnectTimeoutMs() { int result = 0; if (getHelpedParameters().getNames().contains("socketConnectTimeoutMs")) { result = Integer.parseInt(getHelpedParameters().getFirstValue( "socketConnectTimeoutMs", "15000")); } return result; }
} catch (IOException ioe) { getHelper() .getLogger() .log(Level.FINE, "An error occurred during the communication with the remote HTTP server.",
/** * Converts a low-level HTTP call into a high-level uniform call. * * @param client * The HTTP client that will handle the call. * @param request * The high-level request. * @return A new high-level uniform call. */ public ClientCall toSpecific(HttpClientHelper client, Request request) { // Create the low-level HTTP client call ClientCall result = client.create(request); // Add the headers if (result != null) { HeaderUtils.addGeneralHeaders(request, result.getRequestHeaders()); if (request.getEntity() != null) { HeaderUtils.addEntityHeaders(request.getEntity(), result.getRequestHeaders()); } // NOTE: This must stay at the end because the AWS challenge // scheme requires access to all HTTP headers HeaderUtils.addRequestHeaders(request, result.getRequestHeaders()); } return result; }
@Override public synchronized void start() throws Exception { super.start(); getLogger().info("Starting the HTTP client"); }
@Override public synchronized void stop() throws Exception { super.stop(); getLogger().info("Stopping the HTTP client"); }
@Override public synchronized void start() throws Exception { super.start(); getLogger().info("Starting the HTTP client"); }
@Override public synchronized void stop() throws Exception { super.stop(); getLogger().info("Stopping the internal HTTP client"); }
@Override public void start() throws Exception { super.start(); // Define configuration parameters HttpParams params = new BasicHttpParams(); configure(params); // Set-up the scheme registry SchemeRegistry schemeRegistry = new SchemeRegistry(); configure(schemeRegistry); // Create the connection manager ClientConnectionManager connectionManager = createClientConnectionManager( params, schemeRegistry); // Create and configure the HTTP client this.httpClient = new DefaultHttpClient(connectionManager, params); configure(this.httpClient); if (this.idleConnectionReaper != null) { // If a previous reaper is present, stop it this.idleConnectionReaper.stop(); } this.idleConnectionReaper = new HttpIdleConnectionReaper(httpClient, getIdleCheckInterval(), getIdleTimeout()); getLogger().info("Starting the Apache HTTP client"); }