dart:io 问题 HttpException:在收到完整标头之前关闭连接

问题描述

我有服务器和客户端。 服务器已使用 Postman 进行了测试。 我在客户端发布请求时遇到问题。

  try {
    var user = CIMUser('admin','admin');
    packet!.addInstance(user);
    var client = HttpClient();
    request.headers.contentType = ContentType.json;
    request.write(packet.toJson());
    var response = await request.close();
    var result = await response.first;
    print(result);
  }
  catch(e){
    print(e);
  }

"var response = await request.close();" Throws exception "HttpException: Connection closed before full header was received,uri = http://127.0.0.1:8888/user/first"

**get** requests works fine

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)