Skip to content

cookies are not stored #259

@zhenkuncua

Description

@zhenkuncua

In JasonNetworkAction.java, this is the code that obtains an HTTPClient

                OkHttpClient client;
                if(options.has("timeout")) {
                    Object timeout = options.get("timeout");
                    if(timeout instanceof Long) {
                        client = ((Launcher)context.getApplicationContext()).getHttpClient((long)timeout);
                    } else if (timeout instanceof String){
                        Long timeout_int = Long.parseLong((String)timeout);
                        client = ((Launcher)context.getApplicationContext()).getHttpClient(timeout_int);
                    } else {
                        client = ((Launcher)context.getApplicationContext()).getHttpClient(0);
                    }
                } else{
                    client = ((Launcher)context.getApplicationContext()).getHttpClient(0);
                }

This is the getHttpClient method in Launcher.java

        if(timeout > 0) {
            return new OkHttpClient.Builder()
                    .writeTimeout(timeout, TimeUnit.SECONDS)
                    .readTimeout(timeout, TimeUnit.SECONDS)
                    .build();
        } else {
            return new OkHttpClient.Builder().build();
        }
  }

And this is the code that builds a default OkHttpClient()

      dispatcher = new Dispatcher();
      protocols = DEFAULT_PROTOCOLS;
      connectionSpecs = DEFAULT_CONNECTION_SPECS;
      eventListenerFactory = EventListener.factory(EventListener.NONE);
      proxySelector = ProxySelector.getDefault();
      cookieJar = CookieJar.NO_COOKIES;
      socketFactory = SocketFactory.getDefault();
      hostnameVerifier = OkHostnameVerifier.INSTANCE;
      certificatePinner = CertificatePinner.DEFAULT;
      proxyAuthenticator = Authenticator.NONE;
      authenticator = Authenticator.NONE;
      connectionPool = new ConnectionPool();
      dns = Dns.SYSTEM;
      followSslRedirects = true;
      followRedirects = true;
      retryOnConnectionFailure = true;
      connectTimeout = 10_000;
      readTimeout = 10_000;
      writeTimeout = 10_000;
      pingInterval = 0;
    }

So it would seem that cookies will not be persistent, and session will not be handled properly if cookie based session is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions