Android Question Okhttputils2 and redirects

Discussion in 'Android Questions' started by wimpie3, Jun 9, 2019.

  1. wimpie3

    wimpie3 Well-Known Member Licensed User

    A while ago I asked if it was possible to manually handle http redirects which came back from a server (see https://www.b4x.com/android/forum/threads/httprequest-redirects.8132). That possibility was added with the http.protocol.handle-redirects parameter.

    I'm now using okhttptutils2 and that possibility does not seem to be present (anymore)?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. wimpie3

    wimpie3 Well-Known Member Licensed User

    But this means I have to modify the library?
     
  4. DonManfred

    DonManfred Expert Licensed User

    yes. Use the source version, do the changes and use the source instead of the library. You also can compile the modified source as a library again...
     
    Last edited: Jun 11, 2019
    Erel likes this.
  5. wimpie3

    wimpie3 Well-Known Member Licensed User

    The instructions are to replace the initialize Sub in httputils2service with this code (source downloaded on https://www.b4x.com/android/forum/threads/b4x-okhttputils2-ihttputils2-httputils2-source-code.82632/):

    Code:
    Sub Initialize
       
    If hc.IsInitialized = False Then
         TempFolder = 
    File.DirTemp
         
    Dim jo As JavaObject = hc
         
    Dim builder As JavaObject = jo.RunMethod("sharedInit"Array("hc"))
         builder.RunMethod(
    "followRedirects"Array(False))
         jo.SetField(
    "client", builder.RunMethod("build"Null))     
         TaskIdToJob.Initialize
       
    End If
    End Sub
    However, there IS not initialize sub in httputils2service... and when I ADD the sub, I get the error that dirtemp is an unknown member.
     
  6. DonManfred

    DonManfred Expert Licensed User

    no one told that there should be one.
    you need to change the hc.inizialize line in the start_service sub...
     
  7. wimpie3

    wimpie3 Well-Known Member Licensed User

    You mean the Sub Service_Create, Manfred? (the Sub Service_Start is empty).
     
  8. DonManfred

    DonManfred Expert Licensed User

    or create. where the hc.initialize can be found...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice