The content of cookie changed after a day

2019-07-17 20:20发布

问题:

I create a login system for my android app and I get this error:

org.json.JSONException: Value <html><body><script of type java.lang.String cannot be converted to JSONObject

I solved this problem with this solution and override my getHeader() method like this:

class JsonArrayRequest1 extends JsonArrayRequest {
    private static final String KEY_COOKIE = "Cookie";
    private static final String VALUE_CONTENT = "__test=641d2ca6fcd49bad844a6d51bc3f7566; path=/";

    public JsonArrayRequest1(int get, String s, Object o, Response.Listener<JSONArray> listener, Response.ErrorListener errorListener) {
        super(get, s, null, listener, errorListener);
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> headers = new HashMap<>(); 
         headers.put(KEY_COOKIE, VALUE_CONTENT);
        return headers;
    }
}

This solution return the true result. After a day, the content value of testcookie-nginx-module cookie changed. Thus the result is null.

testcookie-nginx-module is a simple security antibots

This is detail of testcookie-nginx-module in Opera browser:

Now the question is: Is it possible to keep the content value of testcookie-nginx-module cookie the same? or Is there best way to get true result after changing testcookie-nginx-module content?

标签: android nginx