Convert wget commands to dio/https requests in flutter using cookies and referer

50 Views Asked by At

I have a working Windows batch script that uses the wget command to automatically download a file from a website. these commands using the cookie and referer features. I wanted to know if there is a version of these commands using flutter, specifically the dio or http packages.

the windows script has the following 2 commands:

bin\wget.exe --no-check-certificate --post-data="Login=xxx&Password=yyy" --save-cookies="cookies.txt" --keep-session-cookies "https://10.0.0.1/Login"

bin\wget.exe --no-check-certificate --load-cookies cookies.txt "https://10.0.0.1/Filebrowser?Path=/files/file.csv&RAW" --referer="https://10.0.0.1/Portal/Portal.mwsl?PrNa=Filebrowser&Path=/file/" -O %{output_folder}%\file.csv

There is a way to convert those commands for flutter?

i tried with dio using

 (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
      (HttpClient dioClient) {
    dioClient.badCertificateCallback =
    ((X509Certificate cert, String host, int port) => true);
    return dioClient;
  };

for --no-check-certificate parameter but I don't know how to manage cookies and referer

0

There are 0 best solutions below