开发者

HttpExchange GET arrived empty

开发者 https://www.devze.com 2023-03-25 12:51 出处:网络
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 a

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号