为什么我的 http 请求正文没有传输到服务器?

Why does my http request body doesn't get transferred to the server?

我发出了一个 ajax http post 请求并在 Fiddler 中尝试了它并且成功了,但是当我尝试 运行 在 Dart 中完全相同的请求时请求正文没有'被转移到服务器。我的 Dart 请求正文有问题吗?

Response response = await client.post(
      'https://intranet.tam.ch/krm/timetable/ajax-get-timetable',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Accept-Language': 'de-ch',
        'Accept-Encoding': 'gzip, deflate, br',
        'Host': 'intranet.tam.ch',
        'Origin': 'https://intranet.tam.ch',
        'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15',
        'Connection': 'keep-alive',
        'Referer': 'https://intranet.tam.ch/krm/calendar',
        'Content-Length': '83',
        'Cookie':
            'school=krm; sturmsession=xx; sturmuser=xx; username=xx',
        'X-Requested-With': 'XMLHttpRequest'
      },
      body:
          'startDate=1597615200000&endDate=598133600000&studentId%5B%5D=x&holidaysOnly=0');


client.close();

print(response.body);

非常感谢任何答案

如果您在永远不会发送 body 的 header 中手动定义 Content-Length,似乎会出现某种奇怪的行为。如果您删除 header 并让库处理 Content-Length 它会起作用。