@Override public String get(String url) throws RobotConnectionException { GetMethod method = new GetMethod(url); return fetch(url, method); }
@Override public String call() throws RobotConnectionException { return get(url); } }));
@Override public String call() throws RobotConnectionException { return postJson(url, body); } }));
@Provides @Singleton protected RobotConnection provideRobotConnection() { HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("RobotConnection").build(); return new HttpRobotConnection( httpClient, Executors.newFixedThreadPool(NUMBER_OF_THREADS, threadFactory)); }
@Override public String postJson(String url, String body) throws RobotConnectionException { PostMethod method = new PostMethod(url); try { method.setRequestEntity(new StringRequestEntity(body, RobotConnection.JSON_CONTENT_TYPE, Charsets.UTF_8.name())); return fetch(url, method); } catch (IOException e) { String msg = "Robot fetch http failure: " + url + ": " + e; throw new RobotConnectionException(msg, e); } }