相关疑难解决方法(0)

Flutter-处理POST请求中的状态码302

我正在尝试使用postFlutter 发送带有DIO包装的请求。

这是请求:

getSessionId() async {

  var csrf = await getCsrftoken();

  var dio = new Dio(new Options(
      baseUrl: "http://xxxxxxx/accounts/login/",
      connectTimeout: 5000,
      receiveTimeout: 100000,
      // 5s
      headers: {
        'Cookie': "csrftoken=" + csrf
      },
      contentType: ContentType.JSON,
      // Transform the response data to a String encoded with UTF8.
      // The default value is [ResponseType.JSON].
      responseType: ResponseType.PLAIN
  ));

  var response;
  response = await dio.post("http://xxxxxxx/accounts/login/",
    data: {
      "username": "xxxxx",
      "password": "xxxxx",
      "csrfmiddlewaretoken" : csrf
    },
    options: new Options(
        contentType: ContentType.parse("application/x-www-form-urlencoded")),
  ); …
Run Code Online (Sandbox Code Playgroud)

post request http-status-code-302 dart flutter

2
推荐指数
3
解决办法
4719
查看次数

标签 统计

dart ×1

flutter ×1

http-status-code-302 ×1

post ×1

request ×1