I'm not able to write cookies on a file
Hello, actually I'm doing some curl actions following redirections:
curl -c ./cookiejar -D ./headers -L 'https://www.myhostname.com' \
-v
curl "https://www.myhostname.com/login/log" -b ./cookiejar -c ./cookiejar -D ./headers -L -H "Content-Type: application/x-www-form-urlencoded" --data-raw "6e3281e31ad9c8c9854d54c4d20cb6f13379f506a204b7fc1556bdc8=1de0c2ed62f6ecee23eb73c122dd08d0&email=mail%40wherevermail.com&password=SuperSecretPass" \
-v
curl -b ./cookiejar -c ./cookiejar -D ./headers -L 'https://www.myhostname.com' \
-v
It happens in this way:
The homepage do a 302 redirect to the /login if there are no session data. And a cookie is generated with some relevant data.
When you do login with credentials you write it with the cookie you previously received. If creds are good, this do a 302 redirect to /embed/redirect, once there this (by js) change the window location to home (https://www.myhostname.com)
Now there, will redirect me to /dashboard
When I transport this to java with your library the first action is
dirCookie = "/some/dir/to/file/cookiejar";
dirHeader = "/some/dir/to/file/headers";
CUrl curl = new CUrl("https://www.hostname.com/")
.cookieJar(dirCookie)
.dumpHeader(dirHeader)
.location();
curl.exec();
cookie = "Cookie:";
arrCookie = new ArrayList<String>();
getCookieResp(curl.getResponseHeaders());
System.out.println("Cookie: "+cookie);
System.out.println("Campo hiddden: "+hiddenField);
Funny thing is after the execution, the cookiejar file is empty, not so the headers file which it fills with the proper header data. Actually I've use an internal function to bring the cookies from the header dump to make it pass some info into the form in the next curl. But without a cookie to pass it with the -b option it won't work. I read something in the cookies section about there are some considerations, but I don't really understand why is it failing to write the cookie. There are no enough information on how to handle this kind of scenarios.
Please if you can help me with this I'll appreciate it