【发布时间】:2014-05-31 06:45:25
【问题描述】:
我正在尝试使用 Dart HttpClient 类(io 库/服务器端!),但我想不出如何对 setRequestHeader 进行 Dart(客户端)调用的 EQUIVALENT。
具体来说,我想将“Content-type”设置为“application/json”
根据这一行(来自客户端):
request.setRequestHeader("Content-type", "application/json");
我使用的格式:
new HttpClient().postUrl(Uri.parse(url))
.then((HttpClientRequest request) => request.close())
.then((HttpClientResponse response) => response.transform(new Utf8Decoder()).listen(_set_dbStats));
当我尝试插入时:
.then((HttpClientRequest request) => request.head("Content-type", "application/json"))
我被告知(在 Dart 编辑器中)head 不是请求方法... (尽管我在 API 中看到它?!)这可能与它正在使用有关吗 作为一个帖子?
提前致谢!
【问题讨论】:
标签: http dart httprequest server-side