I've created a HttpServer based on com.sun.net.httpserver.HttpExchange. in my handler, impementation of com.sun.net.httpserver.HttpHandler, the method public void handle(HttpExchange exchange) gets an exchange with empty requestBody. On the server side i'm using:
server.createC开发者_高级运维ontext("/", new BbHandler());
On my Midlet client i'm using:
String url = "http://localhost:22334/name=john";
Why exchange's requestBody has no data to read? Thanks, Eyal.
The most likely cause is that there is no body to be read. Your provided field is in the URL and would be available in the getRequestURI() call on the exchange object (though it probably won't be in the getQuery() part of the URI object because it is missing the ? separator the URI would expect for query parms), but nothing in the body. Most often a GET request does not have body contents, a PUT or POST request would.
精彩评论