我的Dart代码通过post方法将表单发送到我的GAE python服务器。我想在响应中看到服务器返回所有标头。但我无法执行此操作。你能帮忙吗?
void _httpRequest(url, datas){
HttpRequest request = new HttpRequest()
..open("POST", url, async: true)
..setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
..responseType = "";
// add an event handler that is called when the request finishes
request.onReadyStateChange.listen((_) {
if (request.status == 200) {
_onSuccess(request.responseText);
}else{
_handleTheError(request.responseText);
}
});
request.send(datas);
}
void _onSuccess(msg){
print("success : $msg");
}
void _handleTheError(msg){
print("error : $msg");
}
答案 0 :(得分:1)
request.responseHeaders.forEach((k, v) {
print('Header: $k, value: $v');
});