title: How to read HttpRequest data sent from client, on server
body: <p>How do i read HttpRequest data sent by POST method from client, on the server, in Dart?</p>
  
  <p>I send a message from the client like this:</p>
  
  <pre><code>HttpRequest request = new HttpRequest();
  var url = "http://127.0.0.1:8081";
  request.open("POST", url, async: false);
  
  String data = 'hello from client'; 
  request.send(data);
  </code></pre>
  
  <p>On server i am catching the request like this:</p>
  
  <pre><code>HttpServer.bind('127.0.0.1', 8081).then((server) {
  server.listen((HttpRequest request) {
  
  //DATA SHOULD BE READ HERE 
  
  
  
  });
  });
  </code></pre>
  
  <p>But i cant figure out how to actually read the data... There is not data property in HttpRequest nor anything else...</p>
  
  <p>EDIT This is how i get the answer now:</p>
  
  <pre><code>HttpServer.bind('127.0.0.1', 8081).then((server) {
  server.listen((HttpRequest request) {
    //DATA SHOULD BE READ HERE 
    print("got it");
    print(request.method);
    if(request.method == "POST") {
      print("got it 2");
      List&lt;int&gt; dataBody = new List&lt;int&gt;();
      request.listen(dataBody.addAll, onDone: () {
        var postData = new String.fromCharCodes(dataBody);
        print(postData);
        });
      }
   });
  });
  </code></pre>
  
  <p>But for some reason the request.method is not "POST" but "OPTIONS", and if i change to <code>if(request.method == "OPTIONS")</code> , then print(postData) will still return nothing...</p>