Just started tinkering with Dart and I decided to write a simple Http Server and a client. My server code:
#import
Was facing the same problem. Below is my server code. It just prints the query parameters. Added access control headers to fix the issue.
HttpServer.bind('127.0.0.1', 8080).then((server){
server.listen((HttpRequest request){
request.uri.queryParameters.forEach((param,val){
print(param + '-' + val);
});
request.response.headers.add("Access-Control-Allow-Origin", "*");
request.response.headers.add("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT,OPTIONS");
request.response.statusCode = HttpStatus.OK;
request.response.write("Success!");
request.response.close();
});
});
Hope this helps.
you could simplify your life and run both server/client scripts from the same host:port address. There is a small webserver example at http://www.dartlang.org/articles/io/#web-servers that serves static files too. Add your '/api' handler and make sure your client files are in the same directory. The example server is a lot slower than the Dart Editor builtin server that runs on port 3030.