Hello.
Please help with this situation.
You need to send requests to the server using regular HTTP. At the same time, the server uses the session mechanism for subsequent identification of requests (JSESSIONID || PHPSESSID - it does not matter.)
As a client, I tried to use OkHTTPClient and Retrofit 2. But all my attempts to throw this parameter there is a failure, because the server then sends back a new JSESSIONID.
An example of my actions
interface
@FormUrlEncoded @POST("client/signIn") Call<responseT2> loginPost(@Field("email") String email, @Field("pass") String pass, @Header("Set-Cookie") String string); //----------------------------------------------- в синглтоне создаю: client = new OkHttpClient.Builder() .addNetworkInterceptor(new StethoInterceptor()) .build(); retrofit = new Retrofit.Builder() .baseUrl(http://api.example.net/) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); Code for which I make a request
beck = retrofit.create(BackEndApi.class); // ------------
Call<responseT2> call = beck.loginPost( r.getEmail(), r.getPass(), NewNetUtil.getJSESSIOINID() ); call.enqueue(new Callback<responseT2>() { @Override public void onResponse(Call<responseT2> call, Response<responseT2> response) { NewNetUtil.setJSESSIOINID(response.headers().get("Set-Cookie")); } @Override public void onFailure(Call<responseT2> call, Throwable t) { Log.v("response", "ERORR"); t.printStackTrace(); } .build(); What I need to change or add to the server to accept each of my requests in one session.
I will be grateful ...