Is it possible to prevent HTTPClient from following redirects?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By notamonopoly

I’ve spent hours trying to get this to work so maybe someone can confirm if I’m wasting my time.

Currently I have a script on my server that makes a call to a third party site where I pass in a username and password. That site creates a session and then redirects to another site which takes the session data along with the credentials passed and creates an authentication token. That token allows me to then make calls to their api.

My site uses curl to send the request with the following:

$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('application/x-www-form-urlencoded','Connection: Keep-Alive'));
curl_setopt($curl, CURLOPT_URL, $myurl);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, "");

This works perfectly on my site to get the token generated but of course when I try and achieve the same thing in godot I’m hitting a wall. Using httpRequest does not work because it will redirect without the session data and if I change “max_redirects” to zero the request does not complete (request_completed is never called). If I use httpClient to have more control I don’t see a way to stop a redirect at all.

Any help would be appreciated. I was considering using gdnative to be able to use curl but looking at the amount of effort required, if the only option was to go that route I would probably have to avoid using godot for this particular project.

I have a rather small window to port my web application to a native app, is there anyone that can say if what I’m trying to achieve is doable with godot off the shelf? Is there a better place to ask these questions?

notamonopoly | 2018-03-20 13:18