title: Flutter - Handle status code 302 in POST request
body: <p>I'm trying to send a <code>post</code> request in Flutter with <code>DIO</code> package.</p>
  
  <p>Here is the request: </p>
  
  <pre><code>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")),
    );
  
    print("StatusCode: ");
    print(response.statusCode);
    print("Response cookie: ");   //THESE ARE NOT PRINTED
    print(response.headers);
  }
  </code></pre>
  
  <p>After the request i get: </p>
  
  <pre><code>E/flutter ( 4567): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
      E/flutter ( 4567): DioError [DioErrorType.RESPONSE]: Http status error [302]
      E/flutter ( 4567): #0      getSessionId (file:///C:/get_order/lib/main.dart:36:14)
      E/flutter ( 4567): &lt;asynchronous suspension&gt;
  </code></pre>
  
  <p>From this request i only need to get the <code>sessionid</code> cookie, but the function stop with unhandled exception. </p>