even if you disable followsRedirects, you're going to have to recompile
all your apps (since they all need HU2_PUBLIC). there is no inserting
a disable feature into completed applications.
you have 3 options:
1) do the HU2_PUBLIC build configuration, recompile the apps that need it, run the
snippet that turns off followsRedirects, and get on with your life.
2) modify the okhttputils2.b4xlib library to make hc public, recompile the apps that need
it, run the snippet that turns off followsRedirects, and get on with your life.
3) write your own http client (to replace hc in okhttputils2), turn off followsRedirect,
and get on with your life.
all 3 options require rebuilding all the apps that are going to use the no follow feature.
#1 is the path of least resistance.
#2 is easy. the library is written in b4x; you can do whatever you want with it.
copy the original from the core libraries to your additional libraies folder and rename it
(eg, "nofollow.b4xlib"). okhttputils2.b4xlib is just a zip'd archive. make hc public and
remove references to HU2_PUBLIC (there are only 2 of them). save your mods,
zip the archive back up into a b4xlib library, recompile the apps and use your modified
library instead of okhttputils2. run your snippet. there are several instances of making
a modified b4xlib library mentioned in the forum. it's not my invention.
then, for apps what need to turn off following redirects, you select
your modificed library from the libraries tab. when you look at the
libraries tab, you will see 2 references: one to the core okhttputils2
library and one to your modified library. choose the modified version.
assuming you've haven't messed up, it will function exactly like the
core version, with the added benefit of behaving as if you had added
HU2_PUBLIC as a compiler option. if you have messed up, no harm.
try again until you don't mess up. worst case, you give up and delete the
modified library.
#3 is easy enough. okhttputils2 is a one-stop tool for handling various http requests.
if saves you the trouble of having to do it all yourself. allowing you to set conditional
compiler options makes it even easier more useful, but if all you want is a GET that
ignores redirects, then just write a simple okhttpclient3 client that makes an async GET
request (after turning off followsRedirects). you can copy and paste one of the
examples right out of square's documentation.
-----------------------------------------------------------------------------------------------------------------------------
hc, the okhttp client (the object that does all the work) used in the library
needs to be told not to follow redirects before it is built. since the okhttp
client is a private member of the service class, it cannot be accessed from
outside the library. it needs to be declared public in order to run the snippet
you linked to which turns off following redirects. so, either you use the
conditional compiler option HU2_PUBLIC that makes hc public or you modify the
library that builds hc, and make hc public in the first place.
if you look at the snippet, you will see that it directs the client not to
follow redirects before completing the client's build process. in order to run
the snippet successfully, hc needs to be declared public. that is why it is
necessary, to answer your question.