Trying to implement example using HttpExchange
I'm trying to implement the code under "Asynchronous Exchanges" from this link in the jetty documentation: http://wiki.eclipse.org/Jetty/Tutorial/HttpClient#Asynchronous_Exchanges
HttpExchange exchange = new HttpExchange();
// Optionally set the HTTP method
exchange.setMethod("POST");
exchange.setAddress(new Address("ping.host.com", 80));
exchange.setURI("/ping");
// Or, equivalently, this:
exchange.setURL("http://ping.host.com/ping");
client.send(exchange);
System.out.println("Exchange sent");
I'm trying to figure out which HttpExchange class is being used. I downloaded jetty from here http://download.eclipse.org/j开发者_运维技巧etty/
but couldn't find a reference to HttpExchange anywhere in the files. Could it be the HttpExchange from com.sun.net.httpserver? When I try to use the one from sun I get an error telling me that the class doesn't have an HttpExchange() constructor (with no params).
It's org.eclipse.jetty.client.HttpExchange
, assuming you're using the version from Eclipse.
精彩评论