static CallLog[] readExchangeCallLog(ObjectMapper mapper, ContentExchange exchange) { try { exchange.waitForDone(); String responseJson = exchange.getResponseContent(); return mapper.readValue(responseJson, CallLog[].class); } catch (Exception e) { return new CallLog[0]; } }
public Iterable<String> call(Iterator<String> input) { ArrayList<String> content = new ArrayList<String>(); ArrayList<ContentExchange> cea = new ArrayList<ContentExchange>(); HttpClient client = new HttpClient(); try { client.start(); while (input.hasNext()) { ContentExchange exchange = new ContentExchange(true); exchange.setURL("http://qrzcq.com/call/" + input.next()); client.send(exchange); cea.add(exchange); } for (ContentExchange exchange : cea) { exchange.waitForDone(); content.add(exchange.getResponseContent()); } } catch (Exception e) { } return content; }}); System.out.println(StringUtils.join(result.collect(), ","));
public String processRequest(String url, ContentExchange httpRequest) { ContentExchange httpResponse = sendRequest(url, httpRequest); try { String responseContent = httpResponse.getResponseContent(); int rsc = httpResponse.getResponseStatus(); LOG.info("handleRequest: responseStatus: {}, responseContent: {}", rsc, responseContent); if (rsc < 200 || rsc >= 300) { LOG.error("handleRequest: httpStatusCode: {} ...", rsc); return null; } LOG.info("handleRequest:content: {}", responseContent); return responseContent; } catch (UnsupportedEncodingException e) { LOG.error("get http content exception: {}", e.toString()); } return null; }
int rsc = 0; try { responseContent = httpResponse.getResponseContent(); rsc = httpResponse.getResponseStatus(); } catch (UnsupportedEncodingException e) {
int rsc = 0; try { responseContent = httpResponse.getResponseContent(); rsc = httpResponse.getResponseStatus(); } catch (UnsupportedEncodingException e) {
exchange.waitForDone(); return new JSONObject(new JSONTokener(exchange.getResponseContent()));
int rsc = 0; try { responseContent = httpResponse.getResponseContent(); rsc = httpResponse.getResponseStatus(); } catch (UnsupportedEncodingException e) {
value = ex.getResponseContent(); } catch (UnsupportedEncodingException e) { LOG.error("Failed to get response content: {}", e);