Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get and set cookies #25

Closed
robinrev opened this issue Apr 26, 2017 · 1 comment
Closed

get and set cookies #25

robinrev opened this issue Apr 26, 2017 · 1 comment

Comments

@robinrev
Copy link

hi, how to send request and get response cookies using volley?
this is my function

public void doActionJsonPost() {
    // Request a string response from the provided URL.
    StringRequest stringRequest = new StringRequest(Request.Method.POST, IConstants.BASE_URL + url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    JSONObject jsonObject;
                    try {
                        jsonObject = new JSONObject(response);
                        String msgCode = jsonObject.getString("responseCode");
                    } catch (JSONException e) {
                        LoggingHelper.verbose(e.toString());
                        iHttpAsync.onAsyncFailed(e.toString());
                    } catch (Exception e) {
                        LoggingHelper.verbose(e.toString());
                        iHttpAsync.onAsyncFailed(e.toString());
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    LoggingHelper.verbose("ERROR");
                    iHttpAsync.onAsyncFailed(error.getMessage());
                }
            }){
        @Override
        public byte[] getBody() throws AuthFailureError {
            iHttpAsync.onAsyncProgress();
            return parameters.getBytes();
        }
        @Override
        public String getBodyContentType() {
            return "application/json";
        }
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return getAuthHeader(context);
        }

        @Override
        protected Response<String> parseNetworkResponse(NetworkResponse response) {
            Map<String, String> responseHeaders = response.headers;
            String rawCookies = responseHeaders.get("Set-Cookie");
            return super.parseNetworkResponse(response);
        }
    };

    RequestQueue requestQueue = Volley.newRequestQueue(context);
    requestQueue.add(stringRequest);
}

i've overriden parseNetworkResponse to get header, but there is no cookies in the header
how can I get and set cookie with volley?

@jpd236
Copy link
Collaborator

jpd236 commented Apr 26, 2017

Please use volley-users@ to ask questions about how to use Volley - this is a bug tracker for reporting bugs/issues.

@jpd236 jpd236 closed this as completed Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants