本文整理了Java中org.eclipse.jetty.client.HttpClient.send()
方法的一些代码示例,展示了HttpClient.send()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.send()
方法的具体详情如下:
包路径:org.eclipse.jetty.client.HttpClient
类名称:HttpClient
方法名:send
暂无
代码示例来源:origin: databricks/learning-spark
static Tuple2<String, ContentExchange> createRequestForSign(String sign, HttpClient client) throws Exception {
ContentExchange exchange = new ContentExchange(true);
exchange.setURL("http://new73s.herokuapp.com/qsos/" + sign + ".json");
client.send(exchange);
return new Tuple2(sign, exchange);
}
static ObjectMapper createMapper() {
代码示例来源:origin: 4thline/cling
public StreamResponseMessage call() throws Exception {
if (log.isLoggable(Level.FINE))
log.fine("Sending HTTP request: " + requestMessage);
client.send(exchange);
int exchangeState = exchange.waitForDone();
if (exchangeState == HttpExchange.STATUS_COMPLETED) {
try {
return exchange.createResponse();
} catch (Throwable t) {
log.log(Level.WARNING, "Error reading response: " + requestMessage, Exceptions.unwrap(t));
return null;
}
} else if (exchangeState == HttpExchange.STATUS_CANCELLED) {
// That's ok, happens when we abort the exchange after timeout
return null;
} else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
// The warnings of the "excepted" condition are logged in HttpContentExchange
return null;
} else {
log.warning("Unhandled HTTP exchange status: " + exchangeState);
return null;
}
}
};
代码示例来源:origin: databricks/learning-spark
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(), ","));
代码示例来源:origin: kingthy/TVRemoteIME
public StreamResponseMessage call() throws Exception {
if (log.isLoggable(Level.FINE))
log.fine("Sending HTTP request: " + requestMessage);
client.send(exchange);
int exchangeState = exchange.waitForDone();
if (exchangeState == HttpExchange.STATUS_COMPLETED) {
try {
return exchange.createResponse();
} catch (Throwable t) {
log.log(Level.WARNING, "Error reading response: " + requestMessage, Exceptions.unwrap(t));
return null;
}
} else if (exchangeState == HttpExchange.STATUS_CANCELLED) {
// That's ok, happens when we abort the exchange after timeout
return null;
} else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
// The warnings of the "excepted" condition are logged in HttpContentExchange
return null;
} else {
log.warning("Unhandled HTTP exchange status: " + exchangeState);
return null;
}
}
};
代码示例来源:origin: org.apache.camel/camel-jetty8
public void send(HttpClient client) throws IOException {
client.send(ce);
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
private void send(Request request, Response.CompleteListener listener)
{
if (listener != null)
responseListeners.add(listener);
client.send(request, responseListeners);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
private void send(Request request, Response.CompleteListener listener)
{
if (listener != null)
responseListeners.add(listener);
client.send(request, responseListeners);
}
代码示例来源:origin: org.eclipse.jetty/jetty-client
private void send(HttpRequest request, Response.CompleteListener listener)
{
if (listener != null)
responseListeners.add(listener);
sent();
client.send(request, responseListeners);
}
代码示例来源:origin: org.opendaylight.iotdm/onem2m-core
public ContentExchange sendRequest(String url, ContentExchange httpRequest) {
httpRequest.setURL(url);
try {
httpClient.send(httpRequest);
} catch (IOException e) {
LOG.error("Issues with httpClient.send: {}", e.toString());
}
int ex = HttpExchange.STATUS_EXCEPTED;
// Waits until the exchange is terminated
try {
ex = httpRequest.waitForDone();
} catch (InterruptedException e) {
LOG.error("Issues with waitForDone: {}", e.toString());
}
return httpRequest;
}
代码示例来源:origin: org.opendaylight.iotdm/onem2mbenchmark-impl
public ContentExchange sendRequest(String url, OdlOnem2mHttpRequestPrimitive onem2mRequest) {
onem2mRequest.httpRequest.setURL(url + onem2mRequest.to + "?" + onem2mRequest.uriQueryString);
try {
httpClient.send(onem2mRequest.httpRequest);
} catch (IOException e) {
LOG.error("Issues with httpClient.send: {}", e.toString());
}
int ex = HttpExchange.STATUS_EXCEPTED;
// Waits until the exchange is terminated
try {
ex = onem2mRequest.httpRequest.waitForDone();
} catch (InterruptedException e) {
LOG.error("Issues with waitForDone: {}", e.toString());
}
return onem2mRequest.httpRequest;
}
}
代码示例来源:origin: org.fourthline.cling/cling-core
public StreamResponseMessage call() throws Exception {
if (log.isLoggable(Level.FINE))
log.fine("Sending HTTP request: " + requestMessage);
client.send(exchange);
int exchangeState = exchange.waitForDone();
if (exchangeState == HttpExchange.STATUS_COMPLETED) {
try {
return exchange.createResponse();
} catch (Throwable t) {
log.log(Level.WARNING, "Error reading response: " + requestMessage, Exceptions.unwrap(t));
return null;
}
} else if (exchangeState == HttpExchange.STATUS_CANCELLED) {
// That's ok, happens when we abort the exchange after timeout
return null;
} else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
// The warnings of the "excepted" condition are logged in HttpContentExchange
return null;
} else {
log.warning("Unhandled HTTP exchange status: " + exchangeState);
return null;
}
}
};
代码示例来源:origin: com.github.spullara.mustache.java/network
@Override
public Future<Document> execute() throws IOException {
final SettableFuture<Document> future = SettableFuture.create();
ContentExchange exchange = new ContentExchange() {
protected void onResponseComplete() throws IOException {
super.onResponseComplete();
String responseContent = this.getResponseContent();
try {
future.set(db.parse(new InputSource(responseContent)));
} catch (SAXException e) {
future.setException(e);
}
}
};
exchange.setRequestHeader("Accept", "text/xml, application/xml");
exchange.setMethod("GET");
exchange.setURL(url.toExternalForm());
// start the exchange
client.send(exchange);
return future;
}
}
代码示例来源:origin: org.jmockring/jmockring-jetty
/**
*
*/
private void stopServer() {
HttpClient client = new HttpClient();
try {
final HttpExchange exchange = new HttpExchange();
exchange.setMethod("POST");
exchange.setURL(String.format("http://127.0.0.1:%s/shutdown?secret=%s", port, secret));
client.send(exchange);
log.info("LOG00010: shutdown status {}", exchange.getStatus());
} catch (IOException e) {
log.error("LOG00020: Can't stop server gracefully", e);
}
}
代码示例来源:origin: org.opendaylight.iotdm/onem2m-protocol-http
/**
* HTTP notifications will be set out to subscribers interested in resources from the tree where they have have hung
* onem2m subscription resources
* @param url where do i send this onem2m notify message
* @param payload contents of the notification
*/
@Override
public void sendNotification(String url, String payload) {
ContentExchange ex = new ContentExchange();
ex.setURL(url);
ex.setRequestContentSource(new ByteArrayInputStream(payload.getBytes()));
ex.setRequestContentType(Onem2m.ContentType.APP_VND_NTFY_JSON);
Integer cl = payload != null ? payload.length() : 0;
ex.setRequestHeader("Content-Length", cl.toString());
ex.setMethod("post");
LOG.debug("HTTP: Send notification uri: {}, payload: {}:", url, payload);
try {
client.send(ex);
} catch (IOException e) {
LOG.error("Dropping notification: uri: {}, payload: {}", url, payload);
}
}
代码示例来源:origin: com.github.spullara.mustache.java/network
client.send(exchange);
代码示例来源:origin: org.apache.servicemix/servicemix-http
public void process(MessageExchange exchange) throws Exception {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
NormalizedMessage nm = exchange.getMessage("in");
if (nm == null) {
throw new IllegalStateException("Exchange has no input message");
}
SmxHttpExchange httpEx = new Exchange(exchange);
try {
marshaler.createRequest(exchange, nm, httpEx);
jettyClient.send(httpEx);
} catch (Exception e){
handleException(httpEx, exchange, e);
}
}
}
代码示例来源:origin: org.opendaylight.iotdm/onem2m-protocol-http
client.send(ex);
int state = HttpExchange.STATUS_START;
try {
代码示例来源:origin: jdye64/nifi-addons
.getBytes("UTF-8")));
httpClient.send(exchange);
getLogger().info("Waiting for OAuth login response");
exchange.waitForDone();
代码示例来源:origin: org.openhab.binding/org.openhab.binding.fritzaha
asyncclient.send(postExchange);
} catch (IOException e) {
logger.error("An I/O error occurred while sending the POST request to " + getURL(path));
代码示例来源:origin: org.openhab.binding/org.openhab.binding.fritzaha
/**
* Sends an HTTP GET request using the asynchronous client
*
* @param Path
* Path of the requested resource
* @param Args
* Arguments for the request
* @param Callback
* Callback to handle the response with
*/
public HttpExchange asyncGet(String path, String args, FritzahaCallback callback) {
if (!isAuthenticated())
authenticate();
HttpExchange getExchange = new FritzahaContentExchange(callback);
getExchange.setMethod("GET");
getExchange.setURL(getURL(path, addSID(args)));
try {
asyncclient.send(getExchange);
} catch (IOException e) {
logger.error("An I/O error occurred while sending the GET request " + getURL(path, addSID(args)));
return null;
}
logger.debug("GETting URL " + getURL(path, addSID(args)));
return getExchange;
}
内容来源于网络,如有侵权,请联系作者删除!